From 1cec6be6d772b003743e617761a355934510f0d7 Mon Sep 17 00:00:00 2001 From: David Bruno Vontor Date: Mon, 22 Dec 2025 02:20:43 +0100 Subject: [PATCH] feat(api): generate API models and hooks for public shop configuration and commerce entities - Added generated API hooks and models for public shop configuration, including listing and retrieving configurations. - Introduced models for commerce categories, discount codes, orders, product images, and products with pagination and search parameters. - Ensured all generated files are structured for easy integration with React Query. --- backend/thirdparty/downloader/views.py | 235 +- .../{user/user.ts => account/account.ts} | 0 .../private/advertisement/advertisement.ts | 735 ++++++ frontend/src/api/generated/private/api/api.ts | 1795 -------------- .../private/categories/categories.ts | 725 ------ .../generated/private/commerce/commerce.ts | 2073 +++++++++++++++++ .../private/configuration/configuration.ts | 793 +++++++ .../private/discount-codes/discount-codes.ts | 730 ------ .../{go-pay/go-pay.ts => gopay/gopay.ts} | 0 .../private/models/downloadErrorResponse.ts | 1 - .../private/models/downloadRequest.ts | 71 +- .../generated/private/models/errorResponse.ts | 1 + .../api/generated/private/models/extEnum.ts | 27 - .../generated/private/models/formatEnum.ts | 27 - .../src/api/generated/private/models/index.ts | 8 - .../private/models/videoInfoResponse.ts | 13 +- .../src/api/generated/private/order/order.ts | 102 - .../api/generated/private/orders/orders.ts | 346 --- .../packeta-shipment/packeta-shipment.ts | 357 --- .../private/product-images/product-images.ts | 730 ------ .../generated/private/products/products.ts | 716 ------ .../api/generated/private/refunds/refunds.ts | 716 ------ .../user-password-reset.ts | 194 -- .../user-registration/user-registration.ts | 285 --- .../packet.ts => zasilkovna/zasilkovna.ts} | 340 ++- frontend/src/api/generated/public/account.ts | 706 ++++++ .../src/api/generated/public/advertisement.ts | 88 + .../api/generated/public/authentication.ts | 256 -- frontend/src/api/generated/public/commerce.ts | 1767 ++++++++++++++ .../src/api/generated/public/configuration.ts | 408 ++++ .../src/api/generated/public/downloader.ts | 38 + .../models/apiCommerceCategoriesListParams.ts | 0 .../apiCommerceDiscountCodesListParams.ts | 0 .../models/apiCommerceOrdersListParams.ts | 0 .../apiCommerceProductImagesListParams.ts | 0 .../models/apiCommerceProductsListParams.ts | 0 ...rationPublicShopConfigurationListParams.ts | 0 .../apiDownloaderDownloadRetrieveParams.ts | 2 +- .../public/models/downloadErrorResponse.ts | 1 - .../public/models/downloadRequest.ts | 71 +- .../generated/public/models/errorResponse.ts | 1 + .../api/generated/public/models/extEnum.ts | 27 - .../api/generated/public/models/formatEnum.ts | 27 - .../src/api/generated/public/models/index.ts | 8 +- .../public/models/videoInfoResponse.ts | 13 +- frontend/src/api/privateClient.ts | 12 +- frontend/src/api/publicClient.ts | 12 +- frontend/src/orval.config.ts | 4 +- frontend/src/pages/downloader/Downloader.tsx | 343 ++- 49 files changed, 7580 insertions(+), 7224 deletions(-) rename frontend/src/api/generated/private/{user/user.ts => account/account.ts} (100%) create mode 100644 frontend/src/api/generated/private/advertisement/advertisement.ts delete mode 100644 frontend/src/api/generated/private/categories/categories.ts create mode 100644 frontend/src/api/generated/private/commerce/commerce.ts create mode 100644 frontend/src/api/generated/private/configuration/configuration.ts delete mode 100644 frontend/src/api/generated/private/discount-codes/discount-codes.ts rename frontend/src/api/generated/private/{go-pay/go-pay.ts => gopay/gopay.ts} (100%) delete mode 100644 frontend/src/api/generated/private/models/extEnum.ts delete mode 100644 frontend/src/api/generated/private/models/formatEnum.ts delete mode 100644 frontend/src/api/generated/private/order/order.ts delete mode 100644 frontend/src/api/generated/private/orders/orders.ts delete mode 100644 frontend/src/api/generated/private/packeta-shipment/packeta-shipment.ts delete mode 100644 frontend/src/api/generated/private/product-images/product-images.ts delete mode 100644 frontend/src/api/generated/private/products/products.ts delete mode 100644 frontend/src/api/generated/private/refunds/refunds.ts delete mode 100644 frontend/src/api/generated/private/user-password-reset/user-password-reset.ts delete mode 100644 frontend/src/api/generated/private/user-registration/user-registration.ts rename frontend/src/api/generated/private/{packet/packet.ts => zasilkovna/zasilkovna.ts} (68%) create mode 100644 frontend/src/api/generated/public/account.ts create mode 100644 frontend/src/api/generated/public/advertisement.ts delete mode 100644 frontend/src/api/generated/public/authentication.ts create mode 100644 frontend/src/api/generated/public/commerce.ts create mode 100644 frontend/src/api/generated/public/configuration.ts rename frontend/src/api/generated/{private => public}/models/apiCommerceCategoriesListParams.ts (100%) rename frontend/src/api/generated/{private => public}/models/apiCommerceDiscountCodesListParams.ts (100%) rename frontend/src/api/generated/{private => public}/models/apiCommerceOrdersListParams.ts (100%) rename frontend/src/api/generated/{private => public}/models/apiCommerceProductImagesListParams.ts (100%) rename frontend/src/api/generated/{private => public}/models/apiCommerceProductsListParams.ts (100%) rename frontend/src/api/generated/{private => public}/models/apiConfigurationPublicShopConfigurationListParams.ts (100%) delete mode 100644 frontend/src/api/generated/public/models/extEnum.ts delete mode 100644 frontend/src/api/generated/public/models/formatEnum.ts diff --git a/backend/thirdparty/downloader/views.py b/backend/thirdparty/downloader/views.py index b2ed952..b12bae0 100644 --- a/backend/thirdparty/downloader/views.py +++ b/backend/thirdparty/downloader/views.py @@ -5,6 +5,7 @@ import yt_dlp import tempfile import os import shutil +import mimetypes from rest_framework import serializers from rest_framework.views import APIView @@ -21,28 +22,17 @@ from django.utils import timezone from django.db.models.functions import TruncDay, TruncHour from .models import DownloaderRecord -# Allowed container formats for output/remux -FORMAT_CHOICES = ("mp4", "mkv", "webm", "flv", "mov", "avi", "ogg") +# Common container formats - user can provide any extension supported by ffmpeg FORMAT_HELP = ( - "Choose container format: " + "Container format for the output file. Common formats: " "mp4 (H.264 + AAC, most compatible), " "mkv (flexible, lossless container), " "webm (VP9/AV1 + Opus), " "flv (legacy), mov (Apple-friendly), " - "avi (older), ogg (mostly obsolete)." + "avi (older), ogg, m4a (audio only), mp3 (audio only). " + "The extension will be validated by ffmpeg during conversion." ) -# Minimal mime map by extension -MIME_BY_EXT = { - "mp4": "video/mp4", - "mkv": "video/x-matroska", - "webm": "video/webm", - "flv": "video/x-flv", - "mov": "video/quicktime", - "avi": "video/x-msvideo", - "ogg": "video/ogg", -} - class Downloader(APIView): permission_classes = [AllowAny] authentication_classes = [] @@ -154,28 +144,92 @@ class Downloader(APIView): @extend_schema( tags=["downloader", "public"], summary="Download video from URL", + description=""" + Download video with optional quality constraints and container format conversion. + + **Quality Parameters (optional):** + - If not specified, yt-dlp will automatically select the best available quality. + - `video_quality`: Maximum video height in pixels (e.g., 1080, 720, 480). + - `audio_quality`: Maximum audio bitrate in kbps (e.g., 320, 192, 128). + + **Format/Extension:** + - Any format supported by ffmpeg (mp4, mkv, webm, avi, mov, flv, m4a, mp3, etc.). + - Defaults to 'mp4' if not specified. + - The conversion is handled automatically by ffmpeg in the background. + + **Advanced Options:** + - `subtitles`: Download subtitles (language codes like 'en,cs' or 'all') + - `embed_subtitles`: Embed subtitles into video file + - `embed_thumbnail`: Embed thumbnail as cover art + - `extract_audio`: Extract audio only (ignores video quality) + - `start_time`: Trim start (format: HH:MM:SS or seconds) + - `end_time`: Trim end (format: HH:MM:SS or seconds) + - `playlist_items`: Download specific playlist items (e.g., '1-5,8,10') + - `cookies`: Browser cookies for age-restricted content (Netscape format) + """, request=inline_serializer( name="DownloadRequest", fields={ - "url": serializers.URLField(help_text="Video URL to download"), - "ext": serializers.ChoiceField( - choices=FORMAT_CHOICES, + "url": serializers.URLField(help_text="Video URL to download from supported platforms"), + "ext": serializers.CharField( required=False, default="mp4", help_text=FORMAT_HELP, ), - "format": serializers.ChoiceField( - choices=FORMAT_CHOICES, - required=False, - help_text="Alias of 'ext' (deprecated)." - ), "video_quality": serializers.IntegerField( - required=True, - help_text="Target max video height (e.g. 1080)." + required=False, + allow_null=True, + help_text="Optional: Target max video height in pixels (e.g. 1080, 720). If omitted, best quality is selected." ), "audio_quality": serializers.IntegerField( - required=True, - help_text="Target max audio bitrate in kbps (e.g. 160)." + required=False, + allow_null=True, + help_text="Optional: Target max audio bitrate in kbps (e.g. 320, 192, 128). If omitted, best quality is selected." + ), + "subtitles": serializers.CharField( + required=False, + allow_null=True, + allow_blank=True, + help_text="Language codes (e.g., 'en', 'cs', 'en,cs') or 'all' for all available subtitles" + ), + "embed_subtitles": serializers.BooleanField( + required=False, + default=False, + help_text="Embed subtitles into the video file (requires mkv or mp4 container)" + ), + "embed_thumbnail": serializers.BooleanField( + required=False, + default=False, + help_text="Embed thumbnail as cover art in the file" + ), + "extract_audio": serializers.BooleanField( + required=False, + default=False, + help_text="Extract audio only, ignoring video quality settings" + ), + "start_time": serializers.CharField( + required=False, + allow_null=True, + allow_blank=True, + help_text="Start time for trimming (format: HH:MM:SS or seconds as integer)" + ), + "end_time": serializers.CharField( + required=False, + allow_null=True, + allow_blank=True, + help_text="End time for trimming (format: HH:MM:SS or seconds as integer)" + ), + "playlist_items": serializers.CharField( + required=False, + allow_null=True, + allow_blank=True, + help_text="Playlist items to download (e.g., '1-5,8,10' or '1,2,3')" + ), + "cookies": serializers.CharField( + required=False, + allow_null=True, + allow_blank=True, + help_text="Browser cookies in Netscape format for age-restricted content. Export from browser extensions like 'Get cookies.txt'" ), }, ), @@ -185,38 +239,65 @@ class Downloader(APIView): name="DownloadErrorResponse", fields={ "error": serializers.CharField(), - "allowed": serializers.ListField(child=serializers.CharField(), required=False), }, ), }, ) def post(self, request): url = request.data.get("url") - # Accept ext or legacy format param - ext = (request.data.get("ext") or request.data.get("format") or "mp4").lower() + # Accept ext parameter, default to mp4 + ext = request.data.get("ext", "mp4") - try: - video_quality = int(request.data.get("video_quality")) # height, e.g., 1080 - audio_quality = int(request.data.get("audio_quality")) # abr kbps, e.g., 160 - except Exception: - return Response({"error": "Invalid quality parameters, not integers!"}, status=400) + # Optional quality parameters - only parse if provided + video_quality = None + audio_quality = None + + if request.data.get("video_quality"): + try: + video_quality = int(request.data.get("video_quality")) + except (ValueError, TypeError): + return Response({"error": "Invalid video_quality parameter, must be an integer!"}, status=400) + + if request.data.get("audio_quality"): + try: + audio_quality = int(request.data.get("audio_quality")) + except (ValueError, TypeError): + return Response({"error": "Invalid audio_quality parameter, must be an integer!"}, status=400) + + # Advanced options + subtitles = request.data.get("subtitles") + embed_subtitles = request.data.get("embed_subtitles", False) + embed_thumbnail = request.data.get("embed_thumbnail", False) + extract_audio = request.data.get("extract_audio", False) + start_time = request.data.get("start_time") + end_time = request.data.get("end_time") + playlist_items = request.data.get("playlist_items") + cookies = request.data.get("cookies") if not url: return Response({"error": "URL is required"}, status=400) - if ext not in FORMAT_CHOICES: - return Response({"error": f"Unsupported extension '{ext}'", "allowed": FORMAT_CHOICES}, status=400) + if not ext or not isinstance(ext, str): + return Response({"error": "Extension must be a valid string"}, status=400) # Ensure base tmp dir exists os.makedirs(settings.DOWNLOADER_TMP_DIR, exist_ok=True) tmpdir = tempfile.mkdtemp(prefix="downloader_", dir=settings.DOWNLOADER_TMP_DIR) outtmpl = os.path.join(tmpdir, "download.%(ext)s") - # Build a format selector using requested quality caps - # Example: "bv[height<=1080]+ba[abr<=160]/b" - video_part = f"bv[height<={video_quality}]" if video_quality else "bv*" - audio_part = f"ba[abr<={audio_quality}]" if audio_quality else "ba" - - format_selector = f"{video_part}+{audio_part}/b" + # Build a format selector using optional quality caps + # If quality params are not provided, use best quality + if video_quality is not None and audio_quality is not None: + # Both specified: "bv[height<=1080]+ba[abr<=160]/b" + format_selector = f"bv[height<={video_quality}]+ba[abr<={audio_quality}]/b" + elif video_quality is not None: + # Only video quality specified: "bv[height<=1080]+ba/b" + format_selector = f"bv[height<={video_quality}]+ba/b" + elif audio_quality is not None: + # Only audio quality specified: "bv+ba[abr<=160]/b" + format_selector = f"bv+ba[abr<={audio_quality}]/b" + else: + # No quality constraints, let yt-dlp choose best + format_selector = "b/bv+ba" ydl_options = { @@ -226,11 +307,69 @@ class Downloader(APIView): "quiet": True, "max_filesize": settings.DOWNLOADER_MAX_SIZE_BYTES, "socket_timeout": settings.DOWNLOADER_TIMEOUT, - # remux to container without re-encoding where possible - "postprocessors": [ - {"key": "FFmpegVideoRemuxer", "preferedformat": ext} - ], + "postprocessors": [], } + + # Handle cookies for age-restricted content + if cookies: + # Save cookies to a temporary file + cookie_file = os.path.join(tmpdir, "cookies.txt") + try: + with open(cookie_file, "w") as f: + f.write(cookies) + ydl_options["cookiefile"] = cookie_file + except Exception as e: + shutil.rmtree(tmpdir, ignore_errors=True) + return Response({"error": f"Invalid cookies format: {str(e)}"}, status=400) + + # Subtitles + if subtitles: + if subtitles.lower() == "all": + ydl_options["writesubtitles"] = True + ydl_options["writeautomaticsub"] = True + ydl_options["subtitleslangs"] = ["all"] + else: + ydl_options["writesubtitles"] = True + ydl_options["subtitleslangs"] = [lang.strip() for lang in subtitles.split(",")] + + # Embed subtitles (only for mkv/mp4) + if embed_subtitles and subtitles: + if ext in ["mkv", "mp4"]: + ydl_options["postprocessors"].append({"key": "FFmpegEmbedSubtitle"}) + else: + shutil.rmtree(tmpdir, ignore_errors=True) + return Response({"error": "Subtitle embedding requires mkv or mp4 format"}, status=400) + + # Embed thumbnail + if embed_thumbnail: + ydl_options["writethumbnail"] = True + ydl_options["postprocessors"].append({"key": "EmbedThumbnail"}) + + # Extract audio only + if extract_audio: + ydl_options["postprocessors"].append({ + "key": "FFmpegExtractAudio", + "preferredcodec": ext if ext in ["mp3", "m4a", "opus", "vorbis", "wav"] else "mp3", + }) + + # Download sections (trim) + if start_time or end_time: + download_ranges = {} + if start_time: + download_ranges["start_time"] = start_time + if end_time: + download_ranges["end_time"] = end_time + ydl_options["download_ranges"] = lambda info_dict, ydl: [download_ranges] + + # Playlist items + if playlist_items: + ydl_options["playlist_items"] = playlist_items + + # Add remux postprocessor if not extracting audio + if not extract_audio: + ydl_options["postprocessors"].append( + {"key": "FFmpegVideoRemuxer", "preferedformat": ext} + ) file_path = "" try: @@ -268,7 +407,7 @@ class Downloader(APIView): safe_title = slugify(info.get("title") or "video") filename = f"{safe_title}.{ext}" - content_type = MIME_BY_EXT.get(ext, "application/octet-stream") + content_type = mimetypes.guess_type(filename)[0] or "application/octet-stream" response = StreamingHttpResponse( streaming_content=stream_and_cleanup(file_path, tmpdir), diff --git a/frontend/src/api/generated/private/user/user.ts b/frontend/src/api/generated/private/account/account.ts similarity index 100% rename from frontend/src/api/generated/private/user/user.ts rename to frontend/src/api/generated/private/account/account.ts diff --git a/frontend/src/api/generated/private/advertisement/advertisement.ts b/frontend/src/api/generated/private/advertisement/advertisement.ts new file mode 100644 index 0000000..93f5e98 --- /dev/null +++ b/frontend/src/api/generated/private/advertisement/advertisement.ts @@ -0,0 +1,735 @@ +/** + * Generated by orval v7.17.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.0 + */ +import { useMutation, useQuery } from "@tanstack/react-query"; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + MutationFunction, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseMutationOptions, + UseMutationResult, + UseQueryOptions, + UseQueryResult, +} from "@tanstack/react-query"; + +import type { + ApiAdvertisementContactMessagesListParams, + ContactMe, + PaginatedContactMeList, + PatchedContactMe, +} from ".././models"; + +import { privateMutator } from "../../../privateClient"; + +// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 +type IfEquals = + (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B; + +type WritableKeys = { + [P in keyof T]-?: IfEquals< + { [Q in P]: T[P] }, + { -readonly [Q in P]: T[P] }, + P + >; +}[keyof T]; + +type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( + k: infer I, +) => void + ? I + : never; +type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; + +type Writable = Pick>; +type NonReadonly = [T] extends [UnionToIntersection] + ? { + [P in keyof Writable]: T[P] extends object + ? NonReadonly> + : T[P]; + } + : DistributeReadOnlyOverUnions; + +/** + * @summary List contact messages (admin) + */ +export const apiAdvertisementContactMessagesList = ( + params?: ApiAdvertisementContactMessagesListParams, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/advertisement/contact-messages/`, + method: "GET", + params, + signal, + }); +}; + +export const getApiAdvertisementContactMessagesListQueryKey = ( + params?: ApiAdvertisementContactMessagesListParams, +) => { + return [ + `/api/advertisement/contact-messages/`, + ...(params ? [params] : []), + ] as const; +}; + +export const getApiAdvertisementContactMessagesListQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: ApiAdvertisementContactMessagesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? + getApiAdvertisementContactMessagesListQueryKey(params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiAdvertisementContactMessagesList(params, signal); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiAdvertisementContactMessagesListQueryResult = NonNullable< + Awaited> +>; +export type ApiAdvertisementContactMessagesListQueryError = unknown; + +export function useApiAdvertisementContactMessagesList< + TData = Awaited>, + TError = unknown, +>( + params: undefined | ApiAdvertisementContactMessagesListParams, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiAdvertisementContactMessagesList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiAdvertisementContactMessagesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiAdvertisementContactMessagesList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiAdvertisementContactMessagesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary List contact messages (admin) + */ + +export function useApiAdvertisementContactMessagesList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiAdvertisementContactMessagesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiAdvertisementContactMessagesListQueryOptions( + params, + options, + ); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Create contact message (admin) + */ +export const apiAdvertisementContactMessagesCreate = ( + contactMe: NonReadonly, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/advertisement/contact-messages/`, + method: "POST", + headers: { "Content-Type": "application/json" }, + data: contactMe, + signal, + }); +}; + +export const getApiAdvertisementContactMessagesCreateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiAdvertisementContactMessagesCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { data: NonReadonly } + > = (props) => { + const { data } = props ?? {}; + + return apiAdvertisementContactMessagesCreate(data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiAdvertisementContactMessagesCreateMutationResult = NonNullable< + Awaited> +>; +export type ApiAdvertisementContactMessagesCreateMutationBody = + NonReadonly; +export type ApiAdvertisementContactMessagesCreateMutationError = unknown; + +/** + * @summary Create contact message (admin) + */ +export const useApiAdvertisementContactMessagesCreate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiAdvertisementContactMessagesCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Retrieve contact message (admin) + */ +export const apiAdvertisementContactMessagesRetrieve = ( + id: number, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/advertisement/contact-messages/${id}/`, + method: "GET", + signal, + }); +}; + +export const getApiAdvertisementContactMessagesRetrieveQueryKey = ( + id?: number, +) => { + return [`/api/advertisement/contact-messages/${id}/`] as const; +}; + +export const getApiAdvertisementContactMessagesRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? + getApiAdvertisementContactMessagesRetrieveQueryKey(id); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiAdvertisementContactMessagesRetrieve(id, signal); + + return { + queryKey, + queryFn, + enabled: !!id, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiAdvertisementContactMessagesRetrieveQueryResult = NonNullable< + Awaited> +>; +export type ApiAdvertisementContactMessagesRetrieveQueryError = unknown; + +export function useApiAdvertisementContactMessagesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiAdvertisementContactMessagesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiAdvertisementContactMessagesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Retrieve contact message (admin) + */ + +export function useApiAdvertisementContactMessagesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiAdvertisementContactMessagesRetrieveQueryOptions( + id, + options, + ); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Replace contact message (admin) + */ +export const apiAdvertisementContactMessagesUpdate = ( + id: number, + contactMe: NonReadonly, +) => { + return privateMutator({ + url: `/api/advertisement/contact-messages/${id}/`, + method: "PUT", + headers: { "Content-Type": "application/json" }, + data: contactMe, + }); +}; + +export const getApiAdvertisementContactMessagesUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiAdvertisementContactMessagesUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiAdvertisementContactMessagesUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiAdvertisementContactMessagesUpdateMutationResult = NonNullable< + Awaited> +>; +export type ApiAdvertisementContactMessagesUpdateMutationBody = + NonReadonly; +export type ApiAdvertisementContactMessagesUpdateMutationError = unknown; + +/** + * @summary Replace contact message (admin) + */ +export const useApiAdvertisementContactMessagesUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiAdvertisementContactMessagesUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Update contact message (admin) + */ +export const apiAdvertisementContactMessagesPartialUpdate = ( + id: number, + patchedContactMe: NonReadonly, +) => { + return privateMutator({ + url: `/api/advertisement/contact-messages/${id}/`, + method: "PATCH", + headers: { "Content-Type": "application/json" }, + data: patchedContactMe, + }); +}; + +export const getApiAdvertisementContactMessagesPartialUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiAdvertisementContactMessagesPartialUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiAdvertisementContactMessagesPartialUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiAdvertisementContactMessagesPartialUpdateMutationResult = + NonNullable< + Awaited> + >; +export type ApiAdvertisementContactMessagesPartialUpdateMutationBody = + NonReadonly; +export type ApiAdvertisementContactMessagesPartialUpdateMutationError = unknown; + +/** + * @summary Update contact message (admin) + */ +export const useApiAdvertisementContactMessagesPartialUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiAdvertisementContactMessagesPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Delete contact message (admin) + */ +export const apiAdvertisementContactMessagesDestroy = (id: number) => { + return privateMutator({ + url: `/api/advertisement/contact-messages/${id}/`, + method: "DELETE", + }); +}; + +export const getApiAdvertisementContactMessagesDestroyMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationKey = ["apiAdvertisementContactMessagesDestroy"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number } + > = (props) => { + const { id } = props ?? {}; + + return apiAdvertisementContactMessagesDestroy(id); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiAdvertisementContactMessagesDestroyMutationResult = NonNullable< + Awaited> +>; + +export type ApiAdvertisementContactMessagesDestroyMutationError = unknown; + +/** + * @summary Delete contact message (admin) + */ +export const useApiAdvertisementContactMessagesDestroy = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationOptions = + getApiAdvertisementContactMessagesDestroyMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; diff --git a/frontend/src/api/generated/private/api/api.ts b/frontend/src/api/generated/private/api/api.ts index 5b8dcc8..56eb77e 100644 --- a/frontend/src/api/generated/private/api/api.ts +++ b/frontend/src/api/generated/private/api/api.ts @@ -20,25 +20,14 @@ import type { } from "@tanstack/react-query"; import type { - ApiAdvertisementContactMessagesListParams, - ApiConfigurationAdminShopConfigurationListParams, - ApiConfigurationPublicShopConfigurationListParams, ApiSchemaRetrieve200Four, ApiSchemaRetrieve200One, ApiSchemaRetrieve200Three, ApiSchemaRetrieve200Two, ApiSchemaRetrieveParams, - ContactMe, OrderMini, OrderRead, - PaginatedContactMeList, - PaginatedSiteConfigurationAdminList, - PaginatedSiteConfigurationPublicList, - PatchedContactMe, PatchedOrderRead, - PatchedSiteConfigurationAdmin, - SiteConfigurationAdmin, - SiteConfigurationPublic, } from ".././models"; import { privateMutator } from "../../../privateClient"; @@ -71,720 +60,6 @@ type NonReadonly = [T] extends [UnionToIntersection] } : DistributeReadOnlyOverUnions; -export const apiAdvertisementContactMeCreate = (signal?: AbortSignal) => { - return privateMutator({ - url: `/api/advertisement/contact-me/`, - method: "POST", - signal, - }); -}; - -export const getApiAdvertisementContactMeCreateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - void, - TContext -> => { - const mutationKey = ["apiAdvertisementContactMeCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - void - > = () => { - return apiAdvertisementContactMeCreate(); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiAdvertisementContactMeCreateMutationResult = NonNullable< - Awaited> ->; - -export type ApiAdvertisementContactMeCreateMutationError = unknown; - -export const useApiAdvertisementContactMeCreate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - void, - TContext -> => { - const mutationOptions = - getApiAdvertisementContactMeCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -export const apiAdvertisementContactMessagesList = ( - params?: ApiAdvertisementContactMessagesListParams, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/advertisement/contact-messages/`, - method: "GET", - params, - signal, - }); -}; - -export const getApiAdvertisementContactMessagesListQueryKey = ( - params?: ApiAdvertisementContactMessagesListParams, -) => { - return [ - `/api/advertisement/contact-messages/`, - ...(params ? [params] : []), - ] as const; -}; - -export const getApiAdvertisementContactMessagesListQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - params?: ApiAdvertisementContactMessagesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? - getApiAdvertisementContactMessagesListQueryKey(params); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiAdvertisementContactMessagesList(params, signal); - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiAdvertisementContactMessagesListQueryResult = NonNullable< - Awaited> ->; -export type ApiAdvertisementContactMessagesListQueryError = unknown; - -export function useApiAdvertisementContactMessagesList< - TData = Awaited>, - TError = unknown, ->( - params: undefined | ApiAdvertisementContactMessagesListParams, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiAdvertisementContactMessagesList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiAdvertisementContactMessagesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiAdvertisementContactMessagesList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiAdvertisementContactMessagesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; - -export function useApiAdvertisementContactMessagesList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiAdvertisementContactMessagesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiAdvertisementContactMessagesListQueryOptions( - params, - options, - ); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -export const apiAdvertisementContactMessagesCreate = ( - contactMe: NonReadonly, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/advertisement/contact-messages/`, - method: "POST", - headers: { "Content-Type": "application/json" }, - data: contactMe, - signal, - }); -}; - -export const getApiAdvertisementContactMessagesCreateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiAdvertisementContactMessagesCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { data: NonReadonly } - > = (props) => { - const { data } = props ?? {}; - - return apiAdvertisementContactMessagesCreate(data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiAdvertisementContactMessagesCreateMutationResult = NonNullable< - Awaited> ->; -export type ApiAdvertisementContactMessagesCreateMutationBody = - NonReadonly; -export type ApiAdvertisementContactMessagesCreateMutationError = unknown; - -export const useApiAdvertisementContactMessagesCreate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiAdvertisementContactMessagesCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -export const apiAdvertisementContactMessagesRetrieve = ( - id: number, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/advertisement/contact-messages/${id}/`, - method: "GET", - signal, - }); -}; - -export const getApiAdvertisementContactMessagesRetrieveQueryKey = ( - id?: number, -) => { - return [`/api/advertisement/contact-messages/${id}/`] as const; -}; - -export const getApiAdvertisementContactMessagesRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? - getApiAdvertisementContactMessagesRetrieveQueryKey(id); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiAdvertisementContactMessagesRetrieve(id, signal); - - return { - queryKey, - queryFn, - enabled: !!id, - ...queryOptions, - } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiAdvertisementContactMessagesRetrieveQueryResult = NonNullable< - Awaited> ->; -export type ApiAdvertisementContactMessagesRetrieveQueryError = unknown; - -export function useApiAdvertisementContactMessagesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiAdvertisementContactMessagesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiAdvertisementContactMessagesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; - -export function useApiAdvertisementContactMessagesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiAdvertisementContactMessagesRetrieveQueryOptions( - id, - options, - ); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -export const apiAdvertisementContactMessagesUpdate = ( - id: number, - contactMe: NonReadonly, -) => { - return privateMutator({ - url: `/api/advertisement/contact-messages/${id}/`, - method: "PUT", - headers: { "Content-Type": "application/json" }, - data: contactMe, - }); -}; - -export const getApiAdvertisementContactMessagesUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiAdvertisementContactMessagesUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiAdvertisementContactMessagesUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiAdvertisementContactMessagesUpdateMutationResult = NonNullable< - Awaited> ->; -export type ApiAdvertisementContactMessagesUpdateMutationBody = - NonReadonly; -export type ApiAdvertisementContactMessagesUpdateMutationError = unknown; - -export const useApiAdvertisementContactMessagesUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiAdvertisementContactMessagesUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -export const apiAdvertisementContactMessagesPartialUpdate = ( - id: number, - patchedContactMe: NonReadonly, -) => { - return privateMutator({ - url: `/api/advertisement/contact-messages/${id}/`, - method: "PATCH", - headers: { "Content-Type": "application/json" }, - data: patchedContactMe, - }); -}; - -export const getApiAdvertisementContactMessagesPartialUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiAdvertisementContactMessagesPartialUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiAdvertisementContactMessagesPartialUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiAdvertisementContactMessagesPartialUpdateMutationResult = - NonNullable< - Awaited> - >; -export type ApiAdvertisementContactMessagesPartialUpdateMutationBody = - NonReadonly; -export type ApiAdvertisementContactMessagesPartialUpdateMutationError = unknown; - -export const useApiAdvertisementContactMessagesPartialUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiAdvertisementContactMessagesPartialUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -export const apiAdvertisementContactMessagesDestroy = (id: number) => { - return privateMutator({ - url: `/api/advertisement/contact-messages/${id}/`, - method: "DELETE", - }); -}; - -export const getApiAdvertisementContactMessagesDestroyMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationKey = ["apiAdvertisementContactMessagesDestroy"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number } - > = (props) => { - const { id } = props ?? {}; - - return apiAdvertisementContactMessagesDestroy(id); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiAdvertisementContactMessagesDestroyMutationResult = NonNullable< - Awaited> ->; - -export type ApiAdvertisementContactMessagesDestroyMutationError = unknown; - -export const useApiAdvertisementContactMessagesDestroy = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationOptions = - getApiAdvertisementContactMessagesDestroyMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; export const apiCommerceOrdersCarrierRetrieve = ( id: number, signal?: AbortSignal, @@ -1841,1076 +1116,6 @@ export const useApiCommerceRefundsPublicCreate = < return useMutation(mutationOptions, queryClient); }; -export const apiConfigurationAdminShopConfigurationList = ( - params?: ApiConfigurationAdminShopConfigurationListParams, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/configuration/admin/shop-configuration/`, - method: "GET", - params, - signal, - }); -}; - -export const getApiConfigurationAdminShopConfigurationListQueryKey = ( - params?: ApiConfigurationAdminShopConfigurationListParams, -) => { - return [ - `/api/configuration/admin/shop-configuration/`, - ...(params ? [params] : []), - ] as const; -}; - -export const getApiConfigurationAdminShopConfigurationListQueryOptions = < - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - params?: ApiConfigurationAdminShopConfigurationListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? - getApiConfigurationAdminShopConfigurationListQueryKey(params); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => - apiConfigurationAdminShopConfigurationList(params, signal); - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiConfigurationAdminShopConfigurationListQueryResult = NonNullable< - Awaited> ->; -export type ApiConfigurationAdminShopConfigurationListQueryError = unknown; - -export function useApiConfigurationAdminShopConfigurationList< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - params: undefined | ApiConfigurationAdminShopConfigurationListParams, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited< - ReturnType - >, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiConfigurationAdminShopConfigurationList< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - params?: ApiConfigurationAdminShopConfigurationListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited< - ReturnType - >, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiConfigurationAdminShopConfigurationList< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - params?: ApiConfigurationAdminShopConfigurationListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; - -export function useApiConfigurationAdminShopConfigurationList< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - params?: ApiConfigurationAdminShopConfigurationListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = - getApiConfigurationAdminShopConfigurationListQueryOptions(params, options); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -export const apiConfigurationAdminShopConfigurationCreate = ( - siteConfigurationAdmin: NonReadonly, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/configuration/admin/shop-configuration/`, - method: "POST", - headers: { "Content-Type": "application/json" }, - data: siteConfigurationAdmin, - signal, - }); -}; - -export const getApiConfigurationAdminShopConfigurationCreateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiConfigurationAdminShopConfigurationCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { data: NonReadonly } - > = (props) => { - const { data } = props ?? {}; - - return apiConfigurationAdminShopConfigurationCreate(data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiConfigurationAdminShopConfigurationCreateMutationResult = - NonNullable< - Awaited> - >; -export type ApiConfigurationAdminShopConfigurationCreateMutationBody = - NonReadonly; -export type ApiConfigurationAdminShopConfigurationCreateMutationError = unknown; - -export const useApiConfigurationAdminShopConfigurationCreate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiConfigurationAdminShopConfigurationCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -export const apiConfigurationAdminShopConfigurationRetrieve = ( - id: number, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/configuration/admin/shop-configuration/${id}/`, - method: "GET", - signal, - }); -}; - -export const getApiConfigurationAdminShopConfigurationRetrieveQueryKey = ( - id?: number, -) => { - return [`/api/configuration/admin/shop-configuration/${id}/`] as const; -}; - -export const getApiConfigurationAdminShopConfigurationRetrieveQueryOptions = < - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited< - ReturnType - >, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? - getApiConfigurationAdminShopConfigurationRetrieveQueryKey(id); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => - apiConfigurationAdminShopConfigurationRetrieve(id, signal); - - return { - queryKey, - queryFn, - enabled: !!id, - ...queryOptions, - } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiConfigurationAdminShopConfigurationRetrieveQueryResult = - NonNullable< - Awaited> - >; -export type ApiConfigurationAdminShopConfigurationRetrieveQueryError = unknown; - -export function useApiConfigurationAdminShopConfigurationRetrieve< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - id: number, - options: { - query: Partial< - UseQueryOptions< - Awaited< - ReturnType - >, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited< - ReturnType - >, - TError, - Awaited< - ReturnType - > - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiConfigurationAdminShopConfigurationRetrieve< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited< - ReturnType - >, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited< - ReturnType - >, - TError, - Awaited< - ReturnType - > - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiConfigurationAdminShopConfigurationRetrieve< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited< - ReturnType - >, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; - -export function useApiConfigurationAdminShopConfigurationRetrieve< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited< - ReturnType - >, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = - getApiConfigurationAdminShopConfigurationRetrieveQueryOptions(id, options); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -export const apiConfigurationAdminShopConfigurationUpdate = ( - id: number, - siteConfigurationAdmin: NonReadonly, -) => { - return privateMutator({ - url: `/api/configuration/admin/shop-configuration/${id}/`, - method: "PUT", - headers: { "Content-Type": "application/json" }, - data: siteConfigurationAdmin, - }); -}; - -export const getApiConfigurationAdminShopConfigurationUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiConfigurationAdminShopConfigurationUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiConfigurationAdminShopConfigurationUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiConfigurationAdminShopConfigurationUpdateMutationResult = - NonNullable< - Awaited> - >; -export type ApiConfigurationAdminShopConfigurationUpdateMutationBody = - NonReadonly; -export type ApiConfigurationAdminShopConfigurationUpdateMutationError = unknown; - -export const useApiConfigurationAdminShopConfigurationUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiConfigurationAdminShopConfigurationUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -export const apiConfigurationAdminShopConfigurationPartialUpdate = ( - id: number, - patchedSiteConfigurationAdmin: NonReadonly, -) => { - return privateMutator({ - url: `/api/configuration/admin/shop-configuration/${id}/`, - method: "PATCH", - headers: { "Content-Type": "application/json" }, - data: patchedSiteConfigurationAdmin, - }); -}; - -export const getApiConfigurationAdminShopConfigurationPartialUpdateMutationOptions = - (options?: { - mutation?: UseMutationOptions< - Awaited< - ReturnType - >, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }): UseMutationOptions< - Awaited< - ReturnType - >, - TError, - { id: number; data: NonReadonly }, - TContext - > => { - const mutationKey = ["apiConfigurationAdminShopConfigurationPartialUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited< - ReturnType - >, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiConfigurationAdminShopConfigurationPartialUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; - }; - -export type ApiConfigurationAdminShopConfigurationPartialUpdateMutationResult = - NonNullable< - Awaited< - ReturnType - > - >; -export type ApiConfigurationAdminShopConfigurationPartialUpdateMutationBody = - NonReadonly; -export type ApiConfigurationAdminShopConfigurationPartialUpdateMutationError = - unknown; - -export const useApiConfigurationAdminShopConfigurationPartialUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited< - ReturnType - >, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited< - ReturnType - >, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiConfigurationAdminShopConfigurationPartialUpdateMutationOptions( - options, - ); - - return useMutation(mutationOptions, queryClient); -}; -export const apiConfigurationAdminShopConfigurationDestroy = (id: number) => { - return privateMutator({ - url: `/api/configuration/admin/shop-configuration/${id}/`, - method: "DELETE", - }); -}; - -export const getApiConfigurationAdminShopConfigurationDestroyMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationKey = ["apiConfigurationAdminShopConfigurationDestroy"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number } - > = (props) => { - const { id } = props ?? {}; - - return apiConfigurationAdminShopConfigurationDestroy(id); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiConfigurationAdminShopConfigurationDestroyMutationResult = - NonNullable< - Awaited> - >; - -export type ApiConfigurationAdminShopConfigurationDestroyMutationError = - unknown; - -export const useApiConfigurationAdminShopConfigurationDestroy = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationOptions = - getApiConfigurationAdminShopConfigurationDestroyMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -export const apiConfigurationPublicShopConfigurationList = ( - params?: ApiConfigurationPublicShopConfigurationListParams, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/configuration/public/shop-configuration/`, - method: "GET", - params, - signal, - }); -}; - -export const getApiConfigurationPublicShopConfigurationListQueryKey = ( - params?: ApiConfigurationPublicShopConfigurationListParams, -) => { - return [ - `/api/configuration/public/shop-configuration/`, - ...(params ? [params] : []), - ] as const; -}; - -export const getApiConfigurationPublicShopConfigurationListQueryOptions = < - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - params?: ApiConfigurationPublicShopConfigurationListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? - getApiConfigurationPublicShopConfigurationListQueryKey(params); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => - apiConfigurationPublicShopConfigurationList(params, signal); - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiConfigurationPublicShopConfigurationListQueryResult = - NonNullable< - Awaited> - >; -export type ApiConfigurationPublicShopConfigurationListQueryError = unknown; - -export function useApiConfigurationPublicShopConfigurationList< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - params: undefined | ApiConfigurationPublicShopConfigurationListParams, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited< - ReturnType - >, - TError, - Awaited< - ReturnType - > - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiConfigurationPublicShopConfigurationList< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - params?: ApiConfigurationPublicShopConfigurationListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited< - ReturnType - >, - TError, - Awaited< - ReturnType - > - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiConfigurationPublicShopConfigurationList< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - params?: ApiConfigurationPublicShopConfigurationListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; - -export function useApiConfigurationPublicShopConfigurationList< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - params?: ApiConfigurationPublicShopConfigurationListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = - getApiConfigurationPublicShopConfigurationListQueryOptions(params, options); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -export const apiConfigurationPublicShopConfigurationRetrieve = ( - id: number, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/configuration/public/shop-configuration/${id}/`, - method: "GET", - signal, - }); -}; - -export const getApiConfigurationPublicShopConfigurationRetrieveQueryKey = ( - id?: number, -) => { - return [`/api/configuration/public/shop-configuration/${id}/`] as const; -}; - -export const getApiConfigurationPublicShopConfigurationRetrieveQueryOptions = < - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited< - ReturnType - >, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? - getApiConfigurationPublicShopConfigurationRetrieveQueryKey(id); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => - apiConfigurationPublicShopConfigurationRetrieve(id, signal); - - return { - queryKey, - queryFn, - enabled: !!id, - ...queryOptions, - } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiConfigurationPublicShopConfigurationRetrieveQueryResult = - NonNullable< - Awaited> - >; -export type ApiConfigurationPublicShopConfigurationRetrieveQueryError = unknown; - -export function useApiConfigurationPublicShopConfigurationRetrieve< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - id: number, - options: { - query: Partial< - UseQueryOptions< - Awaited< - ReturnType - >, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited< - ReturnType - >, - TError, - Awaited< - ReturnType - > - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiConfigurationPublicShopConfigurationRetrieve< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited< - ReturnType - >, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited< - ReturnType - >, - TError, - Awaited< - ReturnType - > - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiConfigurationPublicShopConfigurationRetrieve< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited< - ReturnType - >, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; - -export function useApiConfigurationPublicShopConfigurationRetrieve< - TData = Awaited< - ReturnType - >, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited< - ReturnType - >, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = - getApiConfigurationPublicShopConfigurationRetrieveQueryOptions(id, options); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - /** * OpenApi3 schema for this API. Format can be selected via content negotiation. diff --git a/frontend/src/api/generated/private/categories/categories.ts b/frontend/src/api/generated/private/categories/categories.ts deleted file mode 100644 index cb486c4..0000000 --- a/frontend/src/api/generated/private/categories/categories.ts +++ /dev/null @@ -1,725 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ -import { useMutation, useQuery } from "@tanstack/react-query"; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult, -} from "@tanstack/react-query"; - -import type { - ApiCommerceCategoriesListParams, - Category, - PaginatedCategoryList, - PatchedCategory, -} from ".././models"; - -import { privateMutator } from "../../../privateClient"; - -// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = - (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B; - -type WritableKeys = { - [P in keyof T]-?: IfEquals< - { [Q in P]: T[P] }, - { -readonly [Q in P]: T[P] }, - P - >; -}[keyof T]; - -type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( - k: infer I, -) => void - ? I - : never; -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; - -type Writable = Pick>; -type NonReadonly = [T] extends [UnionToIntersection] - ? { - [P in keyof Writable]: T[P] extends object - ? NonReadonly> - : T[P]; - } - : DistributeReadOnlyOverUnions; - -/** - * @summary List categories (public) - */ -export const apiCommerceCategoriesList = ( - params?: ApiCommerceCategoriesListParams, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/categories/`, - method: "GET", - params, - signal, - }); -}; - -export const getApiCommerceCategoriesListQueryKey = ( - params?: ApiCommerceCategoriesListParams, -) => { - return [`/api/commerce/categories/`, ...(params ? [params] : [])] as const; -}; - -export const getApiCommerceCategoriesListQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceCategoriesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiCommerceCategoriesListQueryKey(params); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiCommerceCategoriesList(params, signal); - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiCommerceCategoriesListQueryResult = NonNullable< - Awaited> ->; -export type ApiCommerceCategoriesListQueryError = unknown; - -export function useApiCommerceCategoriesList< - TData = Awaited>, - TError = unknown, ->( - params: undefined | ApiCommerceCategoriesListParams, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceCategoriesList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceCategoriesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceCategoriesList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceCategoriesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary List categories (public) - */ - -export function useApiCommerceCategoriesList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceCategoriesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiCommerceCategoriesListQueryOptions( - params, - options, - ); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -/** - * @summary Create category (auth required) - */ -export const apiCommerceCategoriesCreate = ( - category: NonReadonly, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/categories/`, - method: "POST", - headers: { "Content-Type": "application/json" }, - data: category, - signal, - }); -}; - -export const getApiCommerceCategoriesCreateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceCategoriesCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { data: NonReadonly } - > = (props) => { - const { data } = props ?? {}; - - return apiCommerceCategoriesCreate(data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceCategoriesCreateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceCategoriesCreateMutationBody = NonReadonly; -export type ApiCommerceCategoriesCreateMutationError = unknown; - -/** - * @summary Create category (auth required) - */ -export const useApiCommerceCategoriesCreate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiCommerceCategoriesCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Retrieve category (public) - */ -export const apiCommerceCategoriesRetrieve = ( - id: number, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/categories/${id}/`, - method: "GET", - signal, - }); -}; - -export const getApiCommerceCategoriesRetrieveQueryKey = (id?: number) => { - return [`/api/commerce/categories/${id}/`] as const; -}; - -export const getApiCommerceCategoriesRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiCommerceCategoriesRetrieveQueryKey(id); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiCommerceCategoriesRetrieve(id, signal); - - return { - queryKey, - queryFn, - enabled: !!id, - ...queryOptions, - } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiCommerceCategoriesRetrieveQueryResult = NonNullable< - Awaited> ->; -export type ApiCommerceCategoriesRetrieveQueryError = unknown; - -export function useApiCommerceCategoriesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceCategoriesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceCategoriesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary Retrieve category (public) - */ - -export function useApiCommerceCategoriesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiCommerceCategoriesRetrieveQueryOptions( - id, - options, - ); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -/** - * @summary Replace category (auth required) - */ -export const apiCommerceCategoriesUpdate = ( - id: number, - category: NonReadonly, -) => { - return privateMutator({ - url: `/api/commerce/categories/${id}/`, - method: "PUT", - headers: { "Content-Type": "application/json" }, - data: category, - }); -}; - -export const getApiCommerceCategoriesUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceCategoriesUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiCommerceCategoriesUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceCategoriesUpdateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceCategoriesUpdateMutationBody = NonReadonly; -export type ApiCommerceCategoriesUpdateMutationError = unknown; - -/** - * @summary Replace category (auth required) - */ -export const useApiCommerceCategoriesUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiCommerceCategoriesUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Update category (auth required) - */ -export const apiCommerceCategoriesPartialUpdate = ( - id: number, - patchedCategory: NonReadonly, -) => { - return privateMutator({ - url: `/api/commerce/categories/${id}/`, - method: "PATCH", - headers: { "Content-Type": "application/json" }, - data: patchedCategory, - }); -}; - -export const getApiCommerceCategoriesPartialUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceCategoriesPartialUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiCommerceCategoriesPartialUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceCategoriesPartialUpdateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceCategoriesPartialUpdateMutationBody = - NonReadonly; -export type ApiCommerceCategoriesPartialUpdateMutationError = unknown; - -/** - * @summary Update category (auth required) - */ -export const useApiCommerceCategoriesPartialUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiCommerceCategoriesPartialUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Delete category (auth required) - */ -export const apiCommerceCategoriesDestroy = (id: number) => { - return privateMutator({ - url: `/api/commerce/categories/${id}/`, - method: "DELETE", - }); -}; - -export const getApiCommerceCategoriesDestroyMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationKey = ["apiCommerceCategoriesDestroy"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number } - > = (props) => { - const { id } = props ?? {}; - - return apiCommerceCategoriesDestroy(id); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceCategoriesDestroyMutationResult = NonNullable< - Awaited> ->; - -export type ApiCommerceCategoriesDestroyMutationError = unknown; - -/** - * @summary Delete category (auth required) - */ -export const useApiCommerceCategoriesDestroy = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationOptions = - getApiCommerceCategoriesDestroyMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; diff --git a/frontend/src/api/generated/private/commerce/commerce.ts b/frontend/src/api/generated/private/commerce/commerce.ts new file mode 100644 index 0000000..6155972 --- /dev/null +++ b/frontend/src/api/generated/private/commerce/commerce.ts @@ -0,0 +1,2073 @@ +/** + * Generated by orval v7.17.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.0 + */ +import { useMutation, useQuery } from "@tanstack/react-query"; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + MutationFunction, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseMutationOptions, + UseMutationResult, + UseQueryOptions, + UseQueryResult, +} from "@tanstack/react-query"; + +import type { + ApiCommerceRefundsListParams, + Category, + DiscountCode, + PaginatedRefundList, + PatchedCategory, + PatchedDiscountCode, + PatchedProduct, + PatchedProductImage, + PatchedRefund, + Product, + ProductImage, + Refund, +} from ".././models"; + +import { privateMutator } from "../../../privateClient"; + +// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 +type IfEquals = + (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B; + +type WritableKeys = { + [P in keyof T]-?: IfEquals< + { [Q in P]: T[P] }, + { -readonly [Q in P]: T[P] }, + P + >; +}[keyof T]; + +type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( + k: infer I, +) => void + ? I + : never; +type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; + +type Writable = Pick>; +type NonReadonly = [T] extends [UnionToIntersection] + ? { + [P in keyof Writable]: T[P] extends object + ? NonReadonly> + : T[P]; + } + : DistributeReadOnlyOverUnions; + +/** + * @summary Create category (auth required) + */ +export const apiCommerceCategoriesCreate = ( + category: NonReadonly, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/commerce/categories/`, + method: "POST", + headers: { "Content-Type": "application/json" }, + data: category, + signal, + }); +}; + +export const getApiCommerceCategoriesCreateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceCategoriesCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { data: NonReadonly } + > = (props) => { + const { data } = props ?? {}; + + return apiCommerceCategoriesCreate(data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceCategoriesCreateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceCategoriesCreateMutationBody = NonReadonly; +export type ApiCommerceCategoriesCreateMutationError = unknown; + +/** + * @summary Create category (auth required) + */ +export const useApiCommerceCategoriesCreate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiCommerceCategoriesCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Replace category (auth required) + */ +export const apiCommerceCategoriesUpdate = ( + id: number, + category: NonReadonly, +) => { + return privateMutator({ + url: `/api/commerce/categories/${id}/`, + method: "PUT", + headers: { "Content-Type": "application/json" }, + data: category, + }); +}; + +export const getApiCommerceCategoriesUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceCategoriesUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiCommerceCategoriesUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceCategoriesUpdateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceCategoriesUpdateMutationBody = NonReadonly; +export type ApiCommerceCategoriesUpdateMutationError = unknown; + +/** + * @summary Replace category (auth required) + */ +export const useApiCommerceCategoriesUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiCommerceCategoriesUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Update category (auth required) + */ +export const apiCommerceCategoriesPartialUpdate = ( + id: number, + patchedCategory: NonReadonly, +) => { + return privateMutator({ + url: `/api/commerce/categories/${id}/`, + method: "PATCH", + headers: { "Content-Type": "application/json" }, + data: patchedCategory, + }); +}; + +export const getApiCommerceCategoriesPartialUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceCategoriesPartialUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiCommerceCategoriesPartialUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceCategoriesPartialUpdateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceCategoriesPartialUpdateMutationBody = + NonReadonly; +export type ApiCommerceCategoriesPartialUpdateMutationError = unknown; + +/** + * @summary Update category (auth required) + */ +export const useApiCommerceCategoriesPartialUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiCommerceCategoriesPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Delete category (auth required) + */ +export const apiCommerceCategoriesDestroy = (id: number) => { + return privateMutator({ + url: `/api/commerce/categories/${id}/`, + method: "DELETE", + }); +}; + +export const getApiCommerceCategoriesDestroyMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationKey = ["apiCommerceCategoriesDestroy"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number } + > = (props) => { + const { id } = props ?? {}; + + return apiCommerceCategoriesDestroy(id); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceCategoriesDestroyMutationResult = NonNullable< + Awaited> +>; + +export type ApiCommerceCategoriesDestroyMutationError = unknown; + +/** + * @summary Delete category (auth required) + */ +export const useApiCommerceCategoriesDestroy = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationOptions = + getApiCommerceCategoriesDestroyMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Create discount code (auth required) + */ +export const apiCommerceDiscountCodesCreate = ( + discountCode: NonReadonly, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/commerce/discount-codes/`, + method: "POST", + headers: { "Content-Type": "application/json" }, + data: discountCode, + signal, + }); +}; + +export const getApiCommerceDiscountCodesCreateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceDiscountCodesCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { data: NonReadonly } + > = (props) => { + const { data } = props ?? {}; + + return apiCommerceDiscountCodesCreate(data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceDiscountCodesCreateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceDiscountCodesCreateMutationBody = + NonReadonly; +export type ApiCommerceDiscountCodesCreateMutationError = unknown; + +/** + * @summary Create discount code (auth required) + */ +export const useApiCommerceDiscountCodesCreate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiCommerceDiscountCodesCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Replace discount code (auth required) + */ +export const apiCommerceDiscountCodesUpdate = ( + id: number, + discountCode: NonReadonly, +) => { + return privateMutator({ + url: `/api/commerce/discount-codes/${id}/`, + method: "PUT", + headers: { "Content-Type": "application/json" }, + data: discountCode, + }); +}; + +export const getApiCommerceDiscountCodesUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceDiscountCodesUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiCommerceDiscountCodesUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceDiscountCodesUpdateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceDiscountCodesUpdateMutationBody = + NonReadonly; +export type ApiCommerceDiscountCodesUpdateMutationError = unknown; + +/** + * @summary Replace discount code (auth required) + */ +export const useApiCommerceDiscountCodesUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiCommerceDiscountCodesUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Update discount code (auth required) + */ +export const apiCommerceDiscountCodesPartialUpdate = ( + id: number, + patchedDiscountCode: NonReadonly, +) => { + return privateMutator({ + url: `/api/commerce/discount-codes/${id}/`, + method: "PATCH", + headers: { "Content-Type": "application/json" }, + data: patchedDiscountCode, + }); +}; + +export const getApiCommerceDiscountCodesPartialUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceDiscountCodesPartialUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiCommerceDiscountCodesPartialUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceDiscountCodesPartialUpdateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceDiscountCodesPartialUpdateMutationBody = + NonReadonly; +export type ApiCommerceDiscountCodesPartialUpdateMutationError = unknown; + +/** + * @summary Update discount code (auth required) + */ +export const useApiCommerceDiscountCodesPartialUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiCommerceDiscountCodesPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Delete discount code (auth required) + */ +export const apiCommerceDiscountCodesDestroy = (id: number) => { + return privateMutator({ + url: `/api/commerce/discount-codes/${id}/`, + method: "DELETE", + }); +}; + +export const getApiCommerceDiscountCodesDestroyMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationKey = ["apiCommerceDiscountCodesDestroy"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number } + > = (props) => { + const { id } = props ?? {}; + + return apiCommerceDiscountCodesDestroy(id); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceDiscountCodesDestroyMutationResult = NonNullable< + Awaited> +>; + +export type ApiCommerceDiscountCodesDestroyMutationError = unknown; + +/** + * @summary Delete discount code (auth required) + */ +export const useApiCommerceDiscountCodesDestroy = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationOptions = + getApiCommerceDiscountCodesDestroyMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Create product image (auth required) + */ +export const apiCommerceProductImagesCreate = ( + productImage: NonReadonly, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/commerce/product-images/`, + method: "POST", + headers: { "Content-Type": "application/json" }, + data: productImage, + signal, + }); +}; + +export const getApiCommerceProductImagesCreateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceProductImagesCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { data: NonReadonly } + > = (props) => { + const { data } = props ?? {}; + + return apiCommerceProductImagesCreate(data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceProductImagesCreateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceProductImagesCreateMutationBody = + NonReadonly; +export type ApiCommerceProductImagesCreateMutationError = unknown; + +/** + * @summary Create product image (auth required) + */ +export const useApiCommerceProductImagesCreate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiCommerceProductImagesCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Replace product image (auth required) + */ +export const apiCommerceProductImagesUpdate = ( + id: number, + productImage: NonReadonly, +) => { + return privateMutator({ + url: `/api/commerce/product-images/${id}/`, + method: "PUT", + headers: { "Content-Type": "application/json" }, + data: productImage, + }); +}; + +export const getApiCommerceProductImagesUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceProductImagesUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiCommerceProductImagesUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceProductImagesUpdateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceProductImagesUpdateMutationBody = + NonReadonly; +export type ApiCommerceProductImagesUpdateMutationError = unknown; + +/** + * @summary Replace product image (auth required) + */ +export const useApiCommerceProductImagesUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiCommerceProductImagesUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Update product image (auth required) + */ +export const apiCommerceProductImagesPartialUpdate = ( + id: number, + patchedProductImage: NonReadonly, +) => { + return privateMutator({ + url: `/api/commerce/product-images/${id}/`, + method: "PATCH", + headers: { "Content-Type": "application/json" }, + data: patchedProductImage, + }); +}; + +export const getApiCommerceProductImagesPartialUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceProductImagesPartialUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiCommerceProductImagesPartialUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceProductImagesPartialUpdateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceProductImagesPartialUpdateMutationBody = + NonReadonly; +export type ApiCommerceProductImagesPartialUpdateMutationError = unknown; + +/** + * @summary Update product image (auth required) + */ +export const useApiCommerceProductImagesPartialUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiCommerceProductImagesPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Delete product image (auth required) + */ +export const apiCommerceProductImagesDestroy = (id: number) => { + return privateMutator({ + url: `/api/commerce/product-images/${id}/`, + method: "DELETE", + }); +}; + +export const getApiCommerceProductImagesDestroyMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationKey = ["apiCommerceProductImagesDestroy"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number } + > = (props) => { + const { id } = props ?? {}; + + return apiCommerceProductImagesDestroy(id); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceProductImagesDestroyMutationResult = NonNullable< + Awaited> +>; + +export type ApiCommerceProductImagesDestroyMutationError = unknown; + +/** + * @summary Delete product image (auth required) + */ +export const useApiCommerceProductImagesDestroy = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationOptions = + getApiCommerceProductImagesDestroyMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Create product (auth required) + */ +export const apiCommerceProductsCreate = ( + product: NonReadonly, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/commerce/products/`, + method: "POST", + headers: { "Content-Type": "application/json" }, + data: product, + signal, + }); +}; + +export const getApiCommerceProductsCreateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceProductsCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { data: NonReadonly } + > = (props) => { + const { data } = props ?? {}; + + return apiCommerceProductsCreate(data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceProductsCreateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceProductsCreateMutationBody = NonReadonly; +export type ApiCommerceProductsCreateMutationError = unknown; + +/** + * @summary Create product (auth required) + */ +export const useApiCommerceProductsCreate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationOptions = getApiCommerceProductsCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Replace product (auth required) + */ +export const apiCommerceProductsUpdate = ( + id: number, + product: NonReadonly, +) => { + return privateMutator({ + url: `/api/commerce/products/${id}/`, + method: "PUT", + headers: { "Content-Type": "application/json" }, + data: product, + }); +}; + +export const getApiCommerceProductsUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceProductsUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiCommerceProductsUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceProductsUpdateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceProductsUpdateMutationBody = NonReadonly; +export type ApiCommerceProductsUpdateMutationError = unknown; + +/** + * @summary Replace product (auth required) + */ +export const useApiCommerceProductsUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = getApiCommerceProductsUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Update product (auth required) + */ +export const apiCommerceProductsPartialUpdate = ( + id: number, + patchedProduct: NonReadonly, +) => { + return privateMutator({ + url: `/api/commerce/products/${id}/`, + method: "PATCH", + headers: { "Content-Type": "application/json" }, + data: patchedProduct, + }); +}; + +export const getApiCommerceProductsPartialUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceProductsPartialUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiCommerceProductsPartialUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceProductsPartialUpdateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceProductsPartialUpdateMutationBody = + NonReadonly; +export type ApiCommerceProductsPartialUpdateMutationError = unknown; + +/** + * @summary Update product (auth required) + */ +export const useApiCommerceProductsPartialUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiCommerceProductsPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Delete product (auth required) + */ +export const apiCommerceProductsDestroy = (id: number) => { + return privateMutator({ + url: `/api/commerce/products/${id}/`, + method: "DELETE", + }); +}; + +export const getApiCommerceProductsDestroyMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationKey = ["apiCommerceProductsDestroy"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number } + > = (props) => { + const { id } = props ?? {}; + + return apiCommerceProductsDestroy(id); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceProductsDestroyMutationResult = NonNullable< + Awaited> +>; + +export type ApiCommerceProductsDestroyMutationError = unknown; + +/** + * @summary Delete product (auth required) + */ +export const useApiCommerceProductsDestroy = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationOptions = getApiCommerceProductsDestroyMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary List refunds (admin) + */ +export const apiCommerceRefundsList = ( + params?: ApiCommerceRefundsListParams, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/commerce/refunds/`, + method: "GET", + params, + signal, + }); +}; + +export const getApiCommerceRefundsListQueryKey = ( + params?: ApiCommerceRefundsListParams, +) => { + return [`/api/commerce/refunds/`, ...(params ? [params] : [])] as const; +}; + +export const getApiCommerceRefundsListQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceRefundsListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiCommerceRefundsListQueryKey(params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiCommerceRefundsList(params, signal); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiCommerceRefundsListQueryResult = NonNullable< + Awaited> +>; +export type ApiCommerceRefundsListQueryError = unknown; + +export function useApiCommerceRefundsList< + TData = Awaited>, + TError = unknown, +>( + params: undefined | ApiCommerceRefundsListParams, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceRefundsList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceRefundsListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceRefundsList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceRefundsListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary List refunds (admin) + */ + +export function useApiCommerceRefundsList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceRefundsListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiCommerceRefundsListQueryOptions(params, options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Create refund (admin) + */ +export const apiCommerceRefundsCreate = ( + refund: NonReadonly, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/commerce/refunds/`, + method: "POST", + headers: { "Content-Type": "application/json" }, + data: refund, + signal, + }); +}; + +export const getApiCommerceRefundsCreateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceRefundsCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { data: NonReadonly } + > = (props) => { + const { data } = props ?? {}; + + return apiCommerceRefundsCreate(data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceRefundsCreateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceRefundsCreateMutationBody = NonReadonly; +export type ApiCommerceRefundsCreateMutationError = unknown; + +/** + * @summary Create refund (admin) + */ +export const useApiCommerceRefundsCreate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationOptions = getApiCommerceRefundsCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Retrieve refund (admin) + */ +export const apiCommerceRefundsRetrieve = ( + id: number, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/commerce/refunds/${id}/`, + method: "GET", + signal, + }); +}; + +export const getApiCommerceRefundsRetrieveQueryKey = (id?: number) => { + return [`/api/commerce/refunds/${id}/`] as const; +}; + +export const getApiCommerceRefundsRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiCommerceRefundsRetrieveQueryKey(id); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiCommerceRefundsRetrieve(id, signal); + + return { + queryKey, + queryFn, + enabled: !!id, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiCommerceRefundsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type ApiCommerceRefundsRetrieveQueryError = unknown; + +export function useApiCommerceRefundsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceRefundsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceRefundsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Retrieve refund (admin) + */ + +export function useApiCommerceRefundsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiCommerceRefundsRetrieveQueryOptions(id, options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Replace refund (admin) + */ +export const apiCommerceRefundsUpdate = ( + id: number, + refund: NonReadonly, +) => { + return privateMutator({ + url: `/api/commerce/refunds/${id}/`, + method: "PUT", + headers: { "Content-Type": "application/json" }, + data: refund, + }); +}; + +export const getApiCommerceRefundsUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceRefundsUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiCommerceRefundsUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceRefundsUpdateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceRefundsUpdateMutationBody = NonReadonly; +export type ApiCommerceRefundsUpdateMutationError = unknown; + +/** + * @summary Replace refund (admin) + */ +export const useApiCommerceRefundsUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = getApiCommerceRefundsUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Update refund (admin) + */ +export const apiCommerceRefundsPartialUpdate = ( + id: number, + patchedRefund: NonReadonly, +) => { + return privateMutator({ + url: `/api/commerce/refunds/${id}/`, + method: "PATCH", + headers: { "Content-Type": "application/json" }, + data: patchedRefund, + }); +}; + +export const getApiCommerceRefundsPartialUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiCommerceRefundsPartialUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiCommerceRefundsPartialUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceRefundsPartialUpdateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceRefundsPartialUpdateMutationBody = + NonReadonly; +export type ApiCommerceRefundsPartialUpdateMutationError = unknown; + +/** + * @summary Update refund (admin) + */ +export const useApiCommerceRefundsPartialUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiCommerceRefundsPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Delete refund (admin) + */ +export const apiCommerceRefundsDestroy = (id: number) => { + return privateMutator({ + url: `/api/commerce/refunds/${id}/`, + method: "DELETE", + }); +}; + +export const getApiCommerceRefundsDestroyMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationKey = ["apiCommerceRefundsDestroy"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number } + > = (props) => { + const { id } = props ?? {}; + + return apiCommerceRefundsDestroy(id); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceRefundsDestroyMutationResult = NonNullable< + Awaited> +>; + +export type ApiCommerceRefundsDestroyMutationError = unknown; + +/** + * @summary Delete refund (admin) + */ +export const useApiCommerceRefundsDestroy = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationOptions = getApiCommerceRefundsDestroyMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; diff --git a/frontend/src/api/generated/private/configuration/configuration.ts b/frontend/src/api/generated/private/configuration/configuration.ts new file mode 100644 index 0000000..daf30de --- /dev/null +++ b/frontend/src/api/generated/private/configuration/configuration.ts @@ -0,0 +1,793 @@ +/** + * Generated by orval v7.17.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.0 + */ +import { useMutation, useQuery } from "@tanstack/react-query"; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + MutationFunction, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseMutationOptions, + UseMutationResult, + UseQueryOptions, + UseQueryResult, +} from "@tanstack/react-query"; + +import type { + ApiConfigurationAdminShopConfigurationListParams, + PaginatedSiteConfigurationAdminList, + PatchedSiteConfigurationAdmin, + SiteConfigurationAdmin, +} from ".././models"; + +import { privateMutator } from "../../../privateClient"; + +// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 +type IfEquals = + (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B; + +type WritableKeys = { + [P in keyof T]-?: IfEquals< + { [Q in P]: T[P] }, + { -readonly [Q in P]: T[P] }, + P + >; +}[keyof T]; + +type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( + k: infer I, +) => void + ? I + : never; +type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; + +type Writable = Pick>; +type NonReadonly = [T] extends [UnionToIntersection] + ? { + [P in keyof Writable]: T[P] extends object + ? NonReadonly> + : T[P]; + } + : DistributeReadOnlyOverUnions; + +/** + * @summary List site configuration (admin) + */ +export const apiConfigurationAdminShopConfigurationList = ( + params?: ApiConfigurationAdminShopConfigurationListParams, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/configuration/admin/shop-configuration/`, + method: "GET", + params, + signal, + }); +}; + +export const getApiConfigurationAdminShopConfigurationListQueryKey = ( + params?: ApiConfigurationAdminShopConfigurationListParams, +) => { + return [ + `/api/configuration/admin/shop-configuration/`, + ...(params ? [params] : []), + ] as const; +}; + +export const getApiConfigurationAdminShopConfigurationListQueryOptions = < + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + params?: ApiConfigurationAdminShopConfigurationListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? + getApiConfigurationAdminShopConfigurationListQueryKey(params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => + apiConfigurationAdminShopConfigurationList(params, signal); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiConfigurationAdminShopConfigurationListQueryResult = NonNullable< + Awaited> +>; +export type ApiConfigurationAdminShopConfigurationListQueryError = unknown; + +export function useApiConfigurationAdminShopConfigurationList< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + params: undefined | ApiConfigurationAdminShopConfigurationListParams, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited< + ReturnType + >, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiConfigurationAdminShopConfigurationList< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + params?: ApiConfigurationAdminShopConfigurationListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited< + ReturnType + >, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiConfigurationAdminShopConfigurationList< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + params?: ApiConfigurationAdminShopConfigurationListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary List site configuration (admin) + */ + +export function useApiConfigurationAdminShopConfigurationList< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + params?: ApiConfigurationAdminShopConfigurationListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = + getApiConfigurationAdminShopConfigurationListQueryOptions(params, options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Create site configuration (admin) + */ +export const apiConfigurationAdminShopConfigurationCreate = ( + siteConfigurationAdmin: NonReadonly, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/configuration/admin/shop-configuration/`, + method: "POST", + headers: { "Content-Type": "application/json" }, + data: siteConfigurationAdmin, + signal, + }); +}; + +export const getApiConfigurationAdminShopConfigurationCreateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiConfigurationAdminShopConfigurationCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { data: NonReadonly } + > = (props) => { + const { data } = props ?? {}; + + return apiConfigurationAdminShopConfigurationCreate(data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiConfigurationAdminShopConfigurationCreateMutationResult = + NonNullable< + Awaited> + >; +export type ApiConfigurationAdminShopConfigurationCreateMutationBody = + NonReadonly; +export type ApiConfigurationAdminShopConfigurationCreateMutationError = unknown; + +/** + * @summary Create site configuration (admin) + */ +export const useApiConfigurationAdminShopConfigurationCreate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiConfigurationAdminShopConfigurationCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Retrieve site configuration (admin) + */ +export const apiConfigurationAdminShopConfigurationRetrieve = ( + id: number, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/configuration/admin/shop-configuration/${id}/`, + method: "GET", + signal, + }); +}; + +export const getApiConfigurationAdminShopConfigurationRetrieveQueryKey = ( + id?: number, +) => { + return [`/api/configuration/admin/shop-configuration/${id}/`] as const; +}; + +export const getApiConfigurationAdminShopConfigurationRetrieveQueryOptions = < + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? + getApiConfigurationAdminShopConfigurationRetrieveQueryKey(id); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => + apiConfigurationAdminShopConfigurationRetrieve(id, signal); + + return { + queryKey, + queryFn, + enabled: !!id, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiConfigurationAdminShopConfigurationRetrieveQueryResult = + NonNullable< + Awaited> + >; +export type ApiConfigurationAdminShopConfigurationRetrieveQueryError = unknown; + +export function useApiConfigurationAdminShopConfigurationRetrieve< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + id: number, + options: { + query: Partial< + UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited< + ReturnType + >, + TError, + Awaited< + ReturnType + > + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiConfigurationAdminShopConfigurationRetrieve< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited< + ReturnType + >, + TError, + Awaited< + ReturnType + > + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiConfigurationAdminShopConfigurationRetrieve< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Retrieve site configuration (admin) + */ + +export function useApiConfigurationAdminShopConfigurationRetrieve< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = + getApiConfigurationAdminShopConfigurationRetrieveQueryOptions(id, options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Replace site configuration (admin) + */ +export const apiConfigurationAdminShopConfigurationUpdate = ( + id: number, + siteConfigurationAdmin: NonReadonly, +) => { + return privateMutator({ + url: `/api/configuration/admin/shop-configuration/${id}/`, + method: "PUT", + headers: { "Content-Type": "application/json" }, + data: siteConfigurationAdmin, + }); +}; + +export const getApiConfigurationAdminShopConfigurationUpdateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ["apiConfigurationAdminShopConfigurationUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiConfigurationAdminShopConfigurationUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiConfigurationAdminShopConfigurationUpdateMutationResult = + NonNullable< + Awaited> + >; +export type ApiConfigurationAdminShopConfigurationUpdateMutationBody = + NonReadonly; +export type ApiConfigurationAdminShopConfigurationUpdateMutationError = unknown; + +/** + * @summary Replace site configuration (admin) + */ +export const useApiConfigurationAdminShopConfigurationUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiConfigurationAdminShopConfigurationUpdateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Update site configuration (admin) + */ +export const apiConfigurationAdminShopConfigurationPartialUpdate = ( + id: number, + patchedSiteConfigurationAdmin: NonReadonly, +) => { + return privateMutator({ + url: `/api/configuration/admin/shop-configuration/${id}/`, + method: "PATCH", + headers: { "Content-Type": "application/json" }, + data: patchedSiteConfigurationAdmin, + }); +}; + +export const getApiConfigurationAdminShopConfigurationPartialUpdateMutationOptions = + (options?: { + mutation?: UseMutationOptions< + Awaited< + ReturnType + >, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }): UseMutationOptions< + Awaited< + ReturnType + >, + TError, + { id: number; data: NonReadonly }, + TContext + > => { + const mutationKey = ["apiConfigurationAdminShopConfigurationPartialUpdate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited< + ReturnType + >, + { id: number; data: NonReadonly } + > = (props) => { + const { id, data } = props ?? {}; + + return apiConfigurationAdminShopConfigurationPartialUpdate(id, data); + }; + + return { mutationFn, ...mutationOptions }; + }; + +export type ApiConfigurationAdminShopConfigurationPartialUpdateMutationResult = + NonNullable< + Awaited< + ReturnType + > + >; +export type ApiConfigurationAdminShopConfigurationPartialUpdateMutationBody = + NonReadonly; +export type ApiConfigurationAdminShopConfigurationPartialUpdateMutationError = + unknown; + +/** + * @summary Update site configuration (admin) + */ +export const useApiConfigurationAdminShopConfigurationPartialUpdate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited< + ReturnType + >, + TError, + { id: number; data: NonReadonly }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited< + ReturnType + >, + TError, + { id: number; data: NonReadonly }, + TContext +> => { + const mutationOptions = + getApiConfigurationAdminShopConfigurationPartialUpdateMutationOptions( + options, + ); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Delete site configuration (admin) + */ +export const apiConfigurationAdminShopConfigurationDestroy = (id: number) => { + return privateMutator({ + url: `/api/configuration/admin/shop-configuration/${id}/`, + method: "DELETE", + }); +}; + +export const getApiConfigurationAdminShopConfigurationDestroyMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationKey = ["apiConfigurationAdminShopConfigurationDestroy"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { id: number } + > = (props) => { + const { id } = props ?? {}; + + return apiConfigurationAdminShopConfigurationDestroy(id); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiConfigurationAdminShopConfigurationDestroyMutationResult = + NonNullable< + Awaited> + >; + +export type ApiConfigurationAdminShopConfigurationDestroyMutationError = + unknown; + +/** + * @summary Delete site configuration (admin) + */ +export const useApiConfigurationAdminShopConfigurationDestroy = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: number }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: number }, + TContext +> => { + const mutationOptions = + getApiConfigurationAdminShopConfigurationDestroyMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; diff --git a/frontend/src/api/generated/private/discount-codes/discount-codes.ts b/frontend/src/api/generated/private/discount-codes/discount-codes.ts deleted file mode 100644 index fd668a8..0000000 --- a/frontend/src/api/generated/private/discount-codes/discount-codes.ts +++ /dev/null @@ -1,730 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ -import { useMutation, useQuery } from "@tanstack/react-query"; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult, -} from "@tanstack/react-query"; - -import type { - ApiCommerceDiscountCodesListParams, - DiscountCode, - PaginatedDiscountCodeList, - PatchedDiscountCode, -} from ".././models"; - -import { privateMutator } from "../../../privateClient"; - -// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = - (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B; - -type WritableKeys = { - [P in keyof T]-?: IfEquals< - { [Q in P]: T[P] }, - { -readonly [Q in P]: T[P] }, - P - >; -}[keyof T]; - -type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( - k: infer I, -) => void - ? I - : never; -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; - -type Writable = Pick>; -type NonReadonly = [T] extends [UnionToIntersection] - ? { - [P in keyof Writable]: T[P] extends object - ? NonReadonly> - : T[P]; - } - : DistributeReadOnlyOverUnions; - -/** - * @summary List discount codes (public) - */ -export const apiCommerceDiscountCodesList = ( - params?: ApiCommerceDiscountCodesListParams, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/discount-codes/`, - method: "GET", - params, - signal, - }); -}; - -export const getApiCommerceDiscountCodesListQueryKey = ( - params?: ApiCommerceDiscountCodesListParams, -) => { - return [ - `/api/commerce/discount-codes/`, - ...(params ? [params] : []), - ] as const; -}; - -export const getApiCommerceDiscountCodesListQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceDiscountCodesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiCommerceDiscountCodesListQueryKey(params); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiCommerceDiscountCodesList(params, signal); - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiCommerceDiscountCodesListQueryResult = NonNullable< - Awaited> ->; -export type ApiCommerceDiscountCodesListQueryError = unknown; - -export function useApiCommerceDiscountCodesList< - TData = Awaited>, - TError = unknown, ->( - params: undefined | ApiCommerceDiscountCodesListParams, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceDiscountCodesList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceDiscountCodesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceDiscountCodesList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceDiscountCodesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary List discount codes (public) - */ - -export function useApiCommerceDiscountCodesList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceDiscountCodesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiCommerceDiscountCodesListQueryOptions( - params, - options, - ); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -/** - * @summary Create discount code (auth required) - */ -export const apiCommerceDiscountCodesCreate = ( - discountCode: NonReadonly, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/discount-codes/`, - method: "POST", - headers: { "Content-Type": "application/json" }, - data: discountCode, - signal, - }); -}; - -export const getApiCommerceDiscountCodesCreateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceDiscountCodesCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { data: NonReadonly } - > = (props) => { - const { data } = props ?? {}; - - return apiCommerceDiscountCodesCreate(data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceDiscountCodesCreateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceDiscountCodesCreateMutationBody = - NonReadonly; -export type ApiCommerceDiscountCodesCreateMutationError = unknown; - -/** - * @summary Create discount code (auth required) - */ -export const useApiCommerceDiscountCodesCreate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiCommerceDiscountCodesCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Retrieve discount code (public) - */ -export const apiCommerceDiscountCodesRetrieve = ( - id: number, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/discount-codes/${id}/`, - method: "GET", - signal, - }); -}; - -export const getApiCommerceDiscountCodesRetrieveQueryKey = (id?: number) => { - return [`/api/commerce/discount-codes/${id}/`] as const; -}; - -export const getApiCommerceDiscountCodesRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiCommerceDiscountCodesRetrieveQueryKey(id); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiCommerceDiscountCodesRetrieve(id, signal); - - return { - queryKey, - queryFn, - enabled: !!id, - ...queryOptions, - } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiCommerceDiscountCodesRetrieveQueryResult = NonNullable< - Awaited> ->; -export type ApiCommerceDiscountCodesRetrieveQueryError = unknown; - -export function useApiCommerceDiscountCodesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceDiscountCodesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceDiscountCodesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary Retrieve discount code (public) - */ - -export function useApiCommerceDiscountCodesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiCommerceDiscountCodesRetrieveQueryOptions( - id, - options, - ); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -/** - * @summary Replace discount code (auth required) - */ -export const apiCommerceDiscountCodesUpdate = ( - id: number, - discountCode: NonReadonly, -) => { - return privateMutator({ - url: `/api/commerce/discount-codes/${id}/`, - method: "PUT", - headers: { "Content-Type": "application/json" }, - data: discountCode, - }); -}; - -export const getApiCommerceDiscountCodesUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceDiscountCodesUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiCommerceDiscountCodesUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceDiscountCodesUpdateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceDiscountCodesUpdateMutationBody = - NonReadonly; -export type ApiCommerceDiscountCodesUpdateMutationError = unknown; - -/** - * @summary Replace discount code (auth required) - */ -export const useApiCommerceDiscountCodesUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiCommerceDiscountCodesUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Update discount code (auth required) - */ -export const apiCommerceDiscountCodesPartialUpdate = ( - id: number, - patchedDiscountCode: NonReadonly, -) => { - return privateMutator({ - url: `/api/commerce/discount-codes/${id}/`, - method: "PATCH", - headers: { "Content-Type": "application/json" }, - data: patchedDiscountCode, - }); -}; - -export const getApiCommerceDiscountCodesPartialUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceDiscountCodesPartialUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiCommerceDiscountCodesPartialUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceDiscountCodesPartialUpdateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceDiscountCodesPartialUpdateMutationBody = - NonReadonly; -export type ApiCommerceDiscountCodesPartialUpdateMutationError = unknown; - -/** - * @summary Update discount code (auth required) - */ -export const useApiCommerceDiscountCodesPartialUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiCommerceDiscountCodesPartialUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Delete discount code (auth required) - */ -export const apiCommerceDiscountCodesDestroy = (id: number) => { - return privateMutator({ - url: `/api/commerce/discount-codes/${id}/`, - method: "DELETE", - }); -}; - -export const getApiCommerceDiscountCodesDestroyMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationKey = ["apiCommerceDiscountCodesDestroy"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number } - > = (props) => { - const { id } = props ?? {}; - - return apiCommerceDiscountCodesDestroy(id); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceDiscountCodesDestroyMutationResult = NonNullable< - Awaited> ->; - -export type ApiCommerceDiscountCodesDestroyMutationError = unknown; - -/** - * @summary Delete discount code (auth required) - */ -export const useApiCommerceDiscountCodesDestroy = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationOptions = - getApiCommerceDiscountCodesDestroyMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; diff --git a/frontend/src/api/generated/private/go-pay/go-pay.ts b/frontend/src/api/generated/private/gopay/gopay.ts similarity index 100% rename from frontend/src/api/generated/private/go-pay/go-pay.ts rename to frontend/src/api/generated/private/gopay/gopay.ts diff --git a/frontend/src/api/generated/private/models/downloadErrorResponse.ts b/frontend/src/api/generated/private/models/downloadErrorResponse.ts index 036a310..8724fdb 100644 --- a/frontend/src/api/generated/private/models/downloadErrorResponse.ts +++ b/frontend/src/api/generated/private/models/downloadErrorResponse.ts @@ -6,5 +6,4 @@ export interface DownloadErrorResponse { error: string; - allowed?: string[]; } diff --git a/frontend/src/api/generated/private/models/downloadRequest.ts b/frontend/src/api/generated/private/models/downloadRequest.ts index 0193507..dd61b6f 100644 --- a/frontend/src/api/generated/private/models/downloadRequest.ts +++ b/frontend/src/api/generated/private/models/downloadRequest.ts @@ -3,34 +3,51 @@ * Do not edit manually. * OpenAPI spec version: 0.0.0 */ -import type { ExtEnum } from "./extEnum"; -import type { FormatEnum } from "./formatEnum"; export interface DownloadRequest { - /** Video URL to download */ + /** Video URL to download from supported platforms */ url: string; - /** Choose container format: mp4 (H.264 + AAC, most compatible), mkv (flexible, lossless container), webm (VP9/AV1 + Opus), flv (legacy), mov (Apple-friendly), avi (older), ogg (mostly obsolete). - -* `mp4` - mp4 -* `mkv` - mkv -* `webm` - webm -* `flv` - flv -* `mov` - mov -* `avi` - avi -* `ogg` - ogg */ - ext?: ExtEnum; - /** Alias of 'ext' (deprecated). - -* `mp4` - mp4 -* `mkv` - mkv -* `webm` - webm -* `flv` - flv -* `mov` - mov -* `avi` - avi -* `ogg` - ogg */ - format?: FormatEnum; - /** Target max video height (e.g. 1080). */ - video_quality: number; - /** Target max audio bitrate in kbps (e.g. 160). */ - audio_quality: number; + /** Container format for the output file. Common formats: mp4 (H.264 + AAC, most compatible), mkv (flexible, lossless container), webm (VP9/AV1 + Opus), flv (legacy), mov (Apple-friendly), avi (older), ogg, m4a (audio only), mp3 (audio only). The extension will be validated by ffmpeg during conversion. */ + ext?: string; + /** + * Optional: Target max video height in pixels (e.g. 1080, 720). If omitted, best quality is selected. + * @nullable + */ + video_quality?: number | null; + /** + * Optional: Target max audio bitrate in kbps (e.g. 320, 192, 128). If omitted, best quality is selected. + * @nullable + */ + audio_quality?: number | null; + /** + * Language codes (e.g., 'en', 'cs', 'en,cs') or 'all' for all available subtitles + * @nullable + */ + subtitles?: string | null; + /** Embed subtitles into the video file (requires mkv or mp4 container) */ + embed_subtitles?: boolean; + /** Embed thumbnail as cover art in the file */ + embed_thumbnail?: boolean; + /** Extract audio only, ignoring video quality settings */ + extract_audio?: boolean; + /** + * Start time for trimming (format: HH:MM:SS or seconds as integer) + * @nullable + */ + start_time?: string | null; + /** + * End time for trimming (format: HH:MM:SS or seconds as integer) + * @nullable + */ + end_time?: string | null; + /** + * Playlist items to download (e.g., '1-5,8,10' or '1,2,3') + * @nullable + */ + playlist_items?: string | null; + /** + * Browser cookies in Netscape format for age-restricted content. Export from browser extensions like 'Get cookies.txt' + * @nullable + */ + cookies?: string | null; } diff --git a/frontend/src/api/generated/private/models/errorResponse.ts b/frontend/src/api/generated/private/models/errorResponse.ts index fc2b666..2647109 100644 --- a/frontend/src/api/generated/private/models/errorResponse.ts +++ b/frontend/src/api/generated/private/models/errorResponse.ts @@ -5,5 +5,6 @@ */ export interface ErrorResponse { + /** Error message describing what went wrong */ error: string; } diff --git a/frontend/src/api/generated/private/models/extEnum.ts b/frontend/src/api/generated/private/models/extEnum.ts deleted file mode 100644 index f4ed4f6..0000000 --- a/frontend/src/api/generated/private/models/extEnum.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ - -/** - * * `mp4` - mp4 - * `mkv` - mkv - * `webm` - webm - * `flv` - flv - * `mov` - mov - * `avi` - avi - * `ogg` - ogg - */ -export type ExtEnum = (typeof ExtEnum)[keyof typeof ExtEnum]; - -// eslint-disable-next-line @typescript-eslint/no-redeclare -export const ExtEnum = { - mp4: "mp4", - mkv: "mkv", - webm: "webm", - flv: "flv", - mov: "mov", - avi: "avi", - ogg: "ogg", -} as const; diff --git a/frontend/src/api/generated/private/models/formatEnum.ts b/frontend/src/api/generated/private/models/formatEnum.ts deleted file mode 100644 index aefaf77..0000000 --- a/frontend/src/api/generated/private/models/formatEnum.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ - -/** - * * `mp4` - mp4 - * `mkv` - mkv - * `webm` - webm - * `flv` - flv - * `mov` - mov - * `avi` - avi - * `ogg` - ogg - */ -export type FormatEnum = (typeof FormatEnum)[keyof typeof FormatEnum]; - -// eslint-disable-next-line @typescript-eslint/no-redeclare -export const FormatEnum = { - mp4: "mp4", - mkv: "mkv", - webm: "webm", - flv: "flv", - mov: "mov", - avi: "avi", - ogg: "ogg", -} as const; diff --git a/frontend/src/api/generated/private/models/index.ts b/frontend/src/api/generated/private/models/index.ts index 40bc7e3..ab641ed 100644 --- a/frontend/src/api/generated/private/models/index.ts +++ b/frontend/src/api/generated/private/models/index.ts @@ -7,14 +7,8 @@ export * from "./additionalParam"; export * from "./apiAccountUsersListParams"; export * from "./apiAdvertisementContactMessagesListParams"; -export * from "./apiCommerceCategoriesListParams"; -export * from "./apiCommerceDiscountCodesListParams"; -export * from "./apiCommerceOrdersListParams"; -export * from "./apiCommerceProductImagesListParams"; -export * from "./apiCommerceProductsListParams"; export * from "./apiCommerceRefundsListParams"; export * from "./apiConfigurationAdminShopConfigurationListParams"; -export * from "./apiConfigurationPublicShopConfigurationListParams"; export * from "./apiSchemaRetrieve200Four"; export * from "./apiSchemaRetrieve200One"; export * from "./apiSchemaRetrieve200Three"; @@ -36,8 +30,6 @@ export * from "./downloadErrorResponse"; export * from "./downloadRequest"; export * from "./downloaderStats"; export * from "./errorResponse"; -export * from "./extEnum"; -export * from "./formatEnum"; export * from "./gopayCreatePayment201"; export * from "./gopayGetStatus200"; export * from "./gopayRefundPayment200"; diff --git a/frontend/src/api/generated/private/models/videoInfoResponse.ts b/frontend/src/api/generated/private/models/videoInfoResponse.ts index 9858144..e23e8b1 100644 --- a/frontend/src/api/generated/private/models/videoInfoResponse.ts +++ b/frontend/src/api/generated/private/models/videoInfoResponse.ts @@ -5,11 +5,20 @@ */ export interface VideoInfoResponse { + /** Video title */ title: string; - /** @nullable */ + /** + * Video duration in seconds (null if unavailable) + * @nullable + */ duration: number | null; - /** @nullable */ + /** + * URL to video thumbnail image + * @nullable + */ thumbnail: string | null; + /** List of available video quality options (e.g., '1080p', '720p', '480p') */ video_resolutions: string[]; + /** List of available audio format options */ audio_resolutions: string[]; } diff --git a/frontend/src/api/generated/private/order/order.ts b/frontend/src/api/generated/private/order/order.ts deleted file mode 100644 index 93609c8..0000000 --- a/frontend/src/api/generated/private/order/order.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ -import { useMutation } from "@tanstack/react-query"; -import type { - MutationFunction, - QueryClient, - UseMutationOptions, - UseMutationResult, -} from "@tanstack/react-query"; - -import type { OrderCreate, OrderRead } from ".././models"; - -import { privateMutator } from "../../../privateClient"; - -/** - * @summary Create Order (public) - */ -export const apiCommerceOrdersCreate = ( - orderCreate: OrderCreate, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/orders/`, - method: "POST", - headers: { "Content-Type": "application/json" }, - data: orderCreate, - signal, - }); -}; - -export const getApiCommerceOrdersCreateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: OrderCreate }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { data: OrderCreate }, - TContext -> => { - const mutationKey = ["apiCommerceOrdersCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { data: OrderCreate } - > = (props) => { - const { data } = props ?? {}; - - return apiCommerceOrdersCreate(data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceOrdersCreateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceOrdersCreateMutationBody = OrderCreate; -export type ApiCommerceOrdersCreateMutationError = unknown; - -/** - * @summary Create Order (public) - */ -export const useApiCommerceOrdersCreate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: OrderCreate }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: OrderCreate }, - TContext -> => { - const mutationOptions = getApiCommerceOrdersCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; diff --git a/frontend/src/api/generated/private/orders/orders.ts b/frontend/src/api/generated/private/orders/orders.ts deleted file mode 100644 index b7a1a92..0000000 --- a/frontend/src/api/generated/private/orders/orders.ts +++ /dev/null @@ -1,346 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ -import { useQuery } from "@tanstack/react-query"; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseQueryOptions, - UseQueryResult, -} from "@tanstack/react-query"; - -import type { - ApiCommerceOrdersListParams, - OrderRead, - PaginatedOrderReadList, -} from ".././models"; - -import { privateMutator } from "../../../privateClient"; - -/** - * @summary List Orders (public) - */ -export const apiCommerceOrdersList = ( - params?: ApiCommerceOrdersListParams, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/orders/`, - method: "GET", - params, - signal, - }); -}; - -export const getApiCommerceOrdersListQueryKey = ( - params?: ApiCommerceOrdersListParams, -) => { - return [`/api/commerce/orders/`, ...(params ? [params] : [])] as const; -}; - -export const getApiCommerceOrdersListQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceOrdersListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiCommerceOrdersListQueryKey(params); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiCommerceOrdersList(params, signal); - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiCommerceOrdersListQueryResult = NonNullable< - Awaited> ->; -export type ApiCommerceOrdersListQueryError = unknown; - -export function useApiCommerceOrdersList< - TData = Awaited>, - TError = unknown, ->( - params: undefined | ApiCommerceOrdersListParams, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceOrdersList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceOrdersListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceOrdersList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceOrdersListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary List Orders (public) - */ - -export function useApiCommerceOrdersList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceOrdersListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiCommerceOrdersListQueryOptions(params, options); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -/** - * @summary Retrieve Order (public) - */ -export const apiCommerceOrdersRetrieve = (id: number, signal?: AbortSignal) => { - return privateMutator({ - url: `/api/commerce/orders/${id}/`, - method: "GET", - signal, - }); -}; - -export const getApiCommerceOrdersRetrieveQueryKey = (id?: number) => { - return [`/api/commerce/orders/${id}/`] as const; -}; - -export const getApiCommerceOrdersRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiCommerceOrdersRetrieveQueryKey(id); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiCommerceOrdersRetrieve(id, signal); - - return { - queryKey, - queryFn, - enabled: !!id, - ...queryOptions, - } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiCommerceOrdersRetrieveQueryResult = NonNullable< - Awaited> ->; -export type ApiCommerceOrdersRetrieveQueryError = unknown; - -export function useApiCommerceOrdersRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceOrdersRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceOrdersRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary Retrieve Order (public) - */ - -export function useApiCommerceOrdersRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiCommerceOrdersRetrieveQueryOptions(id, options); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} diff --git a/frontend/src/api/generated/private/packeta-shipment/packeta-shipment.ts b/frontend/src/api/generated/private/packeta-shipment/packeta-shipment.ts deleted file mode 100644 index f68a4f5..0000000 --- a/frontend/src/api/generated/private/packeta-shipment/packeta-shipment.ts +++ /dev/null @@ -1,357 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ -import { useQuery } from "@tanstack/react-query"; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseQueryOptions, - UseQueryResult, -} from "@tanstack/react-query"; - -import type { - ApiZasilkovnaShipmentsListParams, - PaginatedZasilkovnaShipmentList, - ZasilkovnaShipment, -} from ".././models"; - -import { privateMutator } from "../../../privateClient"; - -/** - * Returns a paginated list of Packeta (Zásilkovna) shipments. - * @summary Hromadný shipment - */ -export const apiZasilkovnaShipmentsList = ( - params?: ApiZasilkovnaShipmentsListParams, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/zasilkovna/shipments/`, - method: "GET", - params, - signal, - }); -}; - -export const getApiZasilkovnaShipmentsListQueryKey = ( - params?: ApiZasilkovnaShipmentsListParams, -) => { - return [`/api/zasilkovna/shipments/`, ...(params ? [params] : [])] as const; -}; - -export const getApiZasilkovnaShipmentsListQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - params?: ApiZasilkovnaShipmentsListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiZasilkovnaShipmentsListQueryKey(params); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiZasilkovnaShipmentsList(params, signal); - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiZasilkovnaShipmentsListQueryResult = NonNullable< - Awaited> ->; -export type ApiZasilkovnaShipmentsListQueryError = unknown; - -export function useApiZasilkovnaShipmentsList< - TData = Awaited>, - TError = unknown, ->( - params: undefined | ApiZasilkovnaShipmentsListParams, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiZasilkovnaShipmentsList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiZasilkovnaShipmentsListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiZasilkovnaShipmentsList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiZasilkovnaShipmentsListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary Hromadný shipment - */ - -export function useApiZasilkovnaShipmentsList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiZasilkovnaShipmentsListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiZasilkovnaShipmentsListQueryOptions( - params, - options, - ); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -/** - * Returns detail for a single shipment. - * @summary Detail hromadné zásilky - */ -export const apiZasilkovnaShipmentsRetrieve = ( - id: number, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/zasilkovna/shipments/${id}/`, - method: "GET", - signal, - }); -}; - -export const getApiZasilkovnaShipmentsRetrieveQueryKey = (id?: number) => { - return [`/api/zasilkovna/shipments/${id}/`] as const; -}; - -export const getApiZasilkovnaShipmentsRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiZasilkovnaShipmentsRetrieveQueryKey(id); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiZasilkovnaShipmentsRetrieve(id, signal); - - return { - queryKey, - queryFn, - enabled: !!id, - ...queryOptions, - } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiZasilkovnaShipmentsRetrieveQueryResult = NonNullable< - Awaited> ->; -export type ApiZasilkovnaShipmentsRetrieveQueryError = unknown; - -export function useApiZasilkovnaShipmentsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiZasilkovnaShipmentsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiZasilkovnaShipmentsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary Detail hromadné zásilky - */ - -export function useApiZasilkovnaShipmentsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiZasilkovnaShipmentsRetrieveQueryOptions( - id, - options, - ); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} diff --git a/frontend/src/api/generated/private/product-images/product-images.ts b/frontend/src/api/generated/private/product-images/product-images.ts deleted file mode 100644 index 77780dc..0000000 --- a/frontend/src/api/generated/private/product-images/product-images.ts +++ /dev/null @@ -1,730 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ -import { useMutation, useQuery } from "@tanstack/react-query"; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult, -} from "@tanstack/react-query"; - -import type { - ApiCommerceProductImagesListParams, - PaginatedProductImageList, - PatchedProductImage, - ProductImage, -} from ".././models"; - -import { privateMutator } from "../../../privateClient"; - -// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = - (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B; - -type WritableKeys = { - [P in keyof T]-?: IfEquals< - { [Q in P]: T[P] }, - { -readonly [Q in P]: T[P] }, - P - >; -}[keyof T]; - -type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( - k: infer I, -) => void - ? I - : never; -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; - -type Writable = Pick>; -type NonReadonly = [T] extends [UnionToIntersection] - ? { - [P in keyof Writable]: T[P] extends object - ? NonReadonly> - : T[P]; - } - : DistributeReadOnlyOverUnions; - -/** - * @summary List product images (public) - */ -export const apiCommerceProductImagesList = ( - params?: ApiCommerceProductImagesListParams, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/product-images/`, - method: "GET", - params, - signal, - }); -}; - -export const getApiCommerceProductImagesListQueryKey = ( - params?: ApiCommerceProductImagesListParams, -) => { - return [ - `/api/commerce/product-images/`, - ...(params ? [params] : []), - ] as const; -}; - -export const getApiCommerceProductImagesListQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceProductImagesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiCommerceProductImagesListQueryKey(params); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiCommerceProductImagesList(params, signal); - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiCommerceProductImagesListQueryResult = NonNullable< - Awaited> ->; -export type ApiCommerceProductImagesListQueryError = unknown; - -export function useApiCommerceProductImagesList< - TData = Awaited>, - TError = unknown, ->( - params: undefined | ApiCommerceProductImagesListParams, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceProductImagesList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceProductImagesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceProductImagesList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceProductImagesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary List product images (public) - */ - -export function useApiCommerceProductImagesList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceProductImagesListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiCommerceProductImagesListQueryOptions( - params, - options, - ); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -/** - * @summary Create product image (auth required) - */ -export const apiCommerceProductImagesCreate = ( - productImage: NonReadonly, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/product-images/`, - method: "POST", - headers: { "Content-Type": "application/json" }, - data: productImage, - signal, - }); -}; - -export const getApiCommerceProductImagesCreateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceProductImagesCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { data: NonReadonly } - > = (props) => { - const { data } = props ?? {}; - - return apiCommerceProductImagesCreate(data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceProductImagesCreateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceProductImagesCreateMutationBody = - NonReadonly; -export type ApiCommerceProductImagesCreateMutationError = unknown; - -/** - * @summary Create product image (auth required) - */ -export const useApiCommerceProductImagesCreate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiCommerceProductImagesCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Retrieve product image (public) - */ -export const apiCommerceProductImagesRetrieve = ( - id: number, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/product-images/${id}/`, - method: "GET", - signal, - }); -}; - -export const getApiCommerceProductImagesRetrieveQueryKey = (id?: number) => { - return [`/api/commerce/product-images/${id}/`] as const; -}; - -export const getApiCommerceProductImagesRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiCommerceProductImagesRetrieveQueryKey(id); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiCommerceProductImagesRetrieve(id, signal); - - return { - queryKey, - queryFn, - enabled: !!id, - ...queryOptions, - } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiCommerceProductImagesRetrieveQueryResult = NonNullable< - Awaited> ->; -export type ApiCommerceProductImagesRetrieveQueryError = unknown; - -export function useApiCommerceProductImagesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceProductImagesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceProductImagesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary Retrieve product image (public) - */ - -export function useApiCommerceProductImagesRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiCommerceProductImagesRetrieveQueryOptions( - id, - options, - ); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -/** - * @summary Replace product image (auth required) - */ -export const apiCommerceProductImagesUpdate = ( - id: number, - productImage: NonReadonly, -) => { - return privateMutator({ - url: `/api/commerce/product-images/${id}/`, - method: "PUT", - headers: { "Content-Type": "application/json" }, - data: productImage, - }); -}; - -export const getApiCommerceProductImagesUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceProductImagesUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiCommerceProductImagesUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceProductImagesUpdateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceProductImagesUpdateMutationBody = - NonReadonly; -export type ApiCommerceProductImagesUpdateMutationError = unknown; - -/** - * @summary Replace product image (auth required) - */ -export const useApiCommerceProductImagesUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiCommerceProductImagesUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Update product image (auth required) - */ -export const apiCommerceProductImagesPartialUpdate = ( - id: number, - patchedProductImage: NonReadonly, -) => { - return privateMutator({ - url: `/api/commerce/product-images/${id}/`, - method: "PATCH", - headers: { "Content-Type": "application/json" }, - data: patchedProductImage, - }); -}; - -export const getApiCommerceProductImagesPartialUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceProductImagesPartialUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiCommerceProductImagesPartialUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceProductImagesPartialUpdateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceProductImagesPartialUpdateMutationBody = - NonReadonly; -export type ApiCommerceProductImagesPartialUpdateMutationError = unknown; - -/** - * @summary Update product image (auth required) - */ -export const useApiCommerceProductImagesPartialUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiCommerceProductImagesPartialUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Delete product image (auth required) - */ -export const apiCommerceProductImagesDestroy = (id: number) => { - return privateMutator({ - url: `/api/commerce/product-images/${id}/`, - method: "DELETE", - }); -}; - -export const getApiCommerceProductImagesDestroyMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationKey = ["apiCommerceProductImagesDestroy"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number } - > = (props) => { - const { id } = props ?? {}; - - return apiCommerceProductImagesDestroy(id); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceProductImagesDestroyMutationResult = NonNullable< - Awaited> ->; - -export type ApiCommerceProductImagesDestroyMutationError = unknown; - -/** - * @summary Delete product image (auth required) - */ -export const useApiCommerceProductImagesDestroy = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationOptions = - getApiCommerceProductImagesDestroyMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; diff --git a/frontend/src/api/generated/private/products/products.ts b/frontend/src/api/generated/private/products/products.ts deleted file mode 100644 index 0146c9b..0000000 --- a/frontend/src/api/generated/private/products/products.ts +++ /dev/null @@ -1,716 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ -import { useMutation, useQuery } from "@tanstack/react-query"; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult, -} from "@tanstack/react-query"; - -import type { - ApiCommerceProductsListParams, - PaginatedProductList, - PatchedProduct, - Product, -} from ".././models"; - -import { privateMutator } from "../../../privateClient"; - -// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = - (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B; - -type WritableKeys = { - [P in keyof T]-?: IfEquals< - { [Q in P]: T[P] }, - { -readonly [Q in P]: T[P] }, - P - >; -}[keyof T]; - -type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( - k: infer I, -) => void - ? I - : never; -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; - -type Writable = Pick>; -type NonReadonly = [T] extends [UnionToIntersection] - ? { - [P in keyof Writable]: T[P] extends object - ? NonReadonly> - : T[P]; - } - : DistributeReadOnlyOverUnions; - -/** - * @summary List products (public) - */ -export const apiCommerceProductsList = ( - params?: ApiCommerceProductsListParams, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/products/`, - method: "GET", - params, - signal, - }); -}; - -export const getApiCommerceProductsListQueryKey = ( - params?: ApiCommerceProductsListParams, -) => { - return [`/api/commerce/products/`, ...(params ? [params] : [])] as const; -}; - -export const getApiCommerceProductsListQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceProductsListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiCommerceProductsListQueryKey(params); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiCommerceProductsList(params, signal); - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiCommerceProductsListQueryResult = NonNullable< - Awaited> ->; -export type ApiCommerceProductsListQueryError = unknown; - -export function useApiCommerceProductsList< - TData = Awaited>, - TError = unknown, ->( - params: undefined | ApiCommerceProductsListParams, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceProductsList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceProductsListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceProductsList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceProductsListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary List products (public) - */ - -export function useApiCommerceProductsList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceProductsListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiCommerceProductsListQueryOptions(params, options); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -/** - * @summary Create product (auth required) - */ -export const apiCommerceProductsCreate = ( - product: NonReadonly, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/products/`, - method: "POST", - headers: { "Content-Type": "application/json" }, - data: product, - signal, - }); -}; - -export const getApiCommerceProductsCreateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceProductsCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { data: NonReadonly } - > = (props) => { - const { data } = props ?? {}; - - return apiCommerceProductsCreate(data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceProductsCreateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceProductsCreateMutationBody = NonReadonly; -export type ApiCommerceProductsCreateMutationError = unknown; - -/** - * @summary Create product (auth required) - */ -export const useApiCommerceProductsCreate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationOptions = getApiCommerceProductsCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Retrieve product (public) - */ -export const apiCommerceProductsRetrieve = ( - id: number, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/products/${id}/`, - method: "GET", - signal, - }); -}; - -export const getApiCommerceProductsRetrieveQueryKey = (id?: number) => { - return [`/api/commerce/products/${id}/`] as const; -}; - -export const getApiCommerceProductsRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiCommerceProductsRetrieveQueryKey(id); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiCommerceProductsRetrieve(id, signal); - - return { - queryKey, - queryFn, - enabled: !!id, - ...queryOptions, - } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiCommerceProductsRetrieveQueryResult = NonNullable< - Awaited> ->; -export type ApiCommerceProductsRetrieveQueryError = unknown; - -export function useApiCommerceProductsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceProductsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceProductsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary Retrieve product (public) - */ - -export function useApiCommerceProductsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiCommerceProductsRetrieveQueryOptions(id, options); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -/** - * @summary Replace product (auth required) - */ -export const apiCommerceProductsUpdate = ( - id: number, - product: NonReadonly, -) => { - return privateMutator({ - url: `/api/commerce/products/${id}/`, - method: "PUT", - headers: { "Content-Type": "application/json" }, - data: product, - }); -}; - -export const getApiCommerceProductsUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceProductsUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiCommerceProductsUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceProductsUpdateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceProductsUpdateMutationBody = NonReadonly; -export type ApiCommerceProductsUpdateMutationError = unknown; - -/** - * @summary Replace product (auth required) - */ -export const useApiCommerceProductsUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = getApiCommerceProductsUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Update product (auth required) - */ -export const apiCommerceProductsPartialUpdate = ( - id: number, - patchedProduct: NonReadonly, -) => { - return privateMutator({ - url: `/api/commerce/products/${id}/`, - method: "PATCH", - headers: { "Content-Type": "application/json" }, - data: patchedProduct, - }); -}; - -export const getApiCommerceProductsPartialUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceProductsPartialUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiCommerceProductsPartialUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceProductsPartialUpdateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceProductsPartialUpdateMutationBody = - NonReadonly; -export type ApiCommerceProductsPartialUpdateMutationError = unknown; - -/** - * @summary Update product (auth required) - */ -export const useApiCommerceProductsPartialUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiCommerceProductsPartialUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Delete product (auth required) - */ -export const apiCommerceProductsDestroy = (id: number) => { - return privateMutator({ - url: `/api/commerce/products/${id}/`, - method: "DELETE", - }); -}; - -export const getApiCommerceProductsDestroyMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationKey = ["apiCommerceProductsDestroy"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number } - > = (props) => { - const { id } = props ?? {}; - - return apiCommerceProductsDestroy(id); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceProductsDestroyMutationResult = NonNullable< - Awaited> ->; - -export type ApiCommerceProductsDestroyMutationError = unknown; - -/** - * @summary Delete product (auth required) - */ -export const useApiCommerceProductsDestroy = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationOptions = getApiCommerceProductsDestroyMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; diff --git a/frontend/src/api/generated/private/refunds/refunds.ts b/frontend/src/api/generated/private/refunds/refunds.ts deleted file mode 100644 index 65c54b8..0000000 --- a/frontend/src/api/generated/private/refunds/refunds.ts +++ /dev/null @@ -1,716 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ -import { useMutation, useQuery } from "@tanstack/react-query"; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult, -} from "@tanstack/react-query"; - -import type { - ApiCommerceRefundsListParams, - PaginatedRefundList, - PatchedRefund, - Refund, -} from ".././models"; - -import { privateMutator } from "../../../privateClient"; - -// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = - (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B; - -type WritableKeys = { - [P in keyof T]-?: IfEquals< - { [Q in P]: T[P] }, - { -readonly [Q in P]: T[P] }, - P - >; -}[keyof T]; - -type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( - k: infer I, -) => void - ? I - : never; -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; - -type Writable = Pick>; -type NonReadonly = [T] extends [UnionToIntersection] - ? { - [P in keyof Writable]: T[P] extends object - ? NonReadonly> - : T[P]; - } - : DistributeReadOnlyOverUnions; - -/** - * @summary List refunds (admin) - */ -export const apiCommerceRefundsList = ( - params?: ApiCommerceRefundsListParams, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/refunds/`, - method: "GET", - params, - signal, - }); -}; - -export const getApiCommerceRefundsListQueryKey = ( - params?: ApiCommerceRefundsListParams, -) => { - return [`/api/commerce/refunds/`, ...(params ? [params] : [])] as const; -}; - -export const getApiCommerceRefundsListQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceRefundsListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiCommerceRefundsListQueryKey(params); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiCommerceRefundsList(params, signal); - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiCommerceRefundsListQueryResult = NonNullable< - Awaited> ->; -export type ApiCommerceRefundsListQueryError = unknown; - -export function useApiCommerceRefundsList< - TData = Awaited>, - TError = unknown, ->( - params: undefined | ApiCommerceRefundsListParams, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceRefundsList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceRefundsListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceRefundsList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceRefundsListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary List refunds (admin) - */ - -export function useApiCommerceRefundsList< - TData = Awaited>, - TError = unknown, ->( - params?: ApiCommerceRefundsListParams, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiCommerceRefundsListQueryOptions(params, options); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -/** - * @summary Create refund (admin) - */ -export const apiCommerceRefundsCreate = ( - refund: NonReadonly, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/refunds/`, - method: "POST", - headers: { "Content-Type": "application/json" }, - data: refund, - signal, - }); -}; - -export const getApiCommerceRefundsCreateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceRefundsCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { data: NonReadonly } - > = (props) => { - const { data } = props ?? {}; - - return apiCommerceRefundsCreate(data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceRefundsCreateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceRefundsCreateMutationBody = NonReadonly; -export type ApiCommerceRefundsCreateMutationError = unknown; - -/** - * @summary Create refund (admin) - */ -export const useApiCommerceRefundsCreate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationOptions = getApiCommerceRefundsCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Retrieve refund (admin) - */ -export const apiCommerceRefundsRetrieve = ( - id: number, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/commerce/refunds/${id}/`, - method: "GET", - signal, - }); -}; - -export const getApiCommerceRefundsRetrieveQueryKey = (id?: number) => { - return [`/api/commerce/refunds/${id}/`] as const; -}; - -export const getApiCommerceRefundsRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? getApiCommerceRefundsRetrieveQueryKey(id); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiCommerceRefundsRetrieve(id, signal); - - return { - queryKey, - queryFn, - enabled: !!id, - ...queryOptions, - } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiCommerceRefundsRetrieveQueryResult = NonNullable< - Awaited> ->; -export type ApiCommerceRefundsRetrieveQueryError = unknown; - -export function useApiCommerceRefundsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceRefundsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiCommerceRefundsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary Retrieve refund (admin) - */ - -export function useApiCommerceRefundsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: number, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiCommerceRefundsRetrieveQueryOptions(id, options); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} - -/** - * @summary Replace refund (admin) - */ -export const apiCommerceRefundsUpdate = ( - id: number, - refund: NonReadonly, -) => { - return privateMutator({ - url: `/api/commerce/refunds/${id}/`, - method: "PUT", - headers: { "Content-Type": "application/json" }, - data: refund, - }); -}; - -export const getApiCommerceRefundsUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceRefundsUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiCommerceRefundsUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceRefundsUpdateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceRefundsUpdateMutationBody = NonReadonly; -export type ApiCommerceRefundsUpdateMutationError = unknown; - -/** - * @summary Replace refund (admin) - */ -export const useApiCommerceRefundsUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = getApiCommerceRefundsUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Update refund (admin) - */ -export const apiCommerceRefundsPartialUpdate = ( - id: number, - patchedRefund: NonReadonly, -) => { - return privateMutator({ - url: `/api/commerce/refunds/${id}/`, - method: "PATCH", - headers: { "Content-Type": "application/json" }, - data: patchedRefund, - }); -}; - -export const getApiCommerceRefundsPartialUpdateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ["apiCommerceRefundsPartialUpdate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number; data: NonReadonly } - > = (props) => { - const { id, data } = props ?? {}; - - return apiCommerceRefundsPartialUpdate(id, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceRefundsPartialUpdateMutationResult = NonNullable< - Awaited> ->; -export type ApiCommerceRefundsPartialUpdateMutationBody = - NonReadonly; -export type ApiCommerceRefundsPartialUpdateMutationError = unknown; - -/** - * @summary Update refund (admin) - */ -export const useApiCommerceRefundsPartialUpdate = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number; data: NonReadonly }, - TContext -> => { - const mutationOptions = - getApiCommerceRefundsPartialUpdateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * @summary Delete refund (admin) - */ -export const apiCommerceRefundsDestroy = (id: number) => { - return privateMutator({ - url: `/api/commerce/refunds/${id}/`, - method: "DELETE", - }); -}; - -export const getApiCommerceRefundsDestroyMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationKey = ["apiCommerceRefundsDestroy"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { id: number } - > = (props) => { - const { id } = props ?? {}; - - return apiCommerceRefundsDestroy(id); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiCommerceRefundsDestroyMutationResult = NonNullable< - Awaited> ->; - -export type ApiCommerceRefundsDestroyMutationError = unknown; - -/** - * @summary Delete refund (admin) - */ -export const useApiCommerceRefundsDestroy = < - TError = unknown, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { id: number }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { id: number }, - TContext -> => { - const mutationOptions = getApiCommerceRefundsDestroyMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; diff --git a/frontend/src/api/generated/private/user-password-reset/user-password-reset.ts b/frontend/src/api/generated/private/user-password-reset/user-password-reset.ts deleted file mode 100644 index f6447ba..0000000 --- a/frontend/src/api/generated/private/user-password-reset/user-password-reset.ts +++ /dev/null @@ -1,194 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ -import { useMutation } from "@tanstack/react-query"; -import type { - MutationFunction, - QueryClient, - UseMutationOptions, - UseMutationResult, -} from "@tanstack/react-query"; - -import type { PasswordResetConfirm, PasswordResetRequest } from ".././models"; - -import { privateMutator } from "../../../privateClient"; - -/** - * Request password reset by providing registered email. An email with instructions will be sent. - * @summary Request password reset (send email) - */ -export const apiAccountPasswordResetCreate = ( - passwordResetRequest: PasswordResetRequest, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/account/password-reset/`, - method: "POST", - headers: { "Content-Type": "application/json" }, - data: passwordResetRequest, - signal, - }); -}; - -export const getApiAccountPasswordResetCreateMutationOptions = < - TError = void, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: PasswordResetRequest }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { data: PasswordResetRequest }, - TContext -> => { - const mutationKey = ["apiAccountPasswordResetCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { data: PasswordResetRequest } - > = (props) => { - const { data } = props ?? {}; - - return apiAccountPasswordResetCreate(data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiAccountPasswordResetCreateMutationResult = NonNullable< - Awaited> ->; -export type ApiAccountPasswordResetCreateMutationBody = PasswordResetRequest; -export type ApiAccountPasswordResetCreateMutationError = void; - -/** - * @summary Request password reset (send email) - */ -export const useApiAccountPasswordResetCreate = < - TError = void, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: PasswordResetRequest }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: PasswordResetRequest }, - TContext -> => { - const mutationOptions = - getApiAccountPasswordResetCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * Confirm password reset using token from email. - * @summary Confirm password reset via token - */ -export const apiAccountPasswordResetConfirmCreate = ( - uidb64: string, - token: string, - passwordResetConfirm: PasswordResetConfirm, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/account/password-reset-confirm/${uidb64}/${token}/`, - method: "POST", - headers: { "Content-Type": "application/json" }, - data: passwordResetConfirm, - signal, - }); -}; - -export const getApiAccountPasswordResetConfirmCreateMutationOptions = < - TError = void, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidb64: string; token: string; data: PasswordResetConfirm }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { uidb64: string; token: string; data: PasswordResetConfirm }, - TContext -> => { - const mutationKey = ["apiAccountPasswordResetConfirmCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { uidb64: string; token: string; data: PasswordResetConfirm } - > = (props) => { - const { uidb64, token, data } = props ?? {}; - - return apiAccountPasswordResetConfirmCreate(uidb64, token, data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiAccountPasswordResetConfirmCreateMutationResult = NonNullable< - Awaited> ->; -export type ApiAccountPasswordResetConfirmCreateMutationBody = - PasswordResetConfirm; -export type ApiAccountPasswordResetConfirmCreateMutationError = void; - -/** - * @summary Confirm password reset via token - */ -export const useApiAccountPasswordResetConfirmCreate = < - TError = void, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidb64: string; token: string; data: PasswordResetConfirm }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { uidb64: string; token: string; data: PasswordResetConfirm }, - TContext -> => { - const mutationOptions = - getApiAccountPasswordResetConfirmCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; diff --git a/frontend/src/api/generated/private/user-registration/user-registration.ts b/frontend/src/api/generated/private/user-registration/user-registration.ts deleted file mode 100644 index f22e399..0000000 --- a/frontend/src/api/generated/private/user-registration/user-registration.ts +++ /dev/null @@ -1,285 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ -import { useMutation, useQuery } from "@tanstack/react-query"; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult, -} from "@tanstack/react-query"; - -import type { UserRegistration } from ".././models"; - -import { privateMutator } from "../../../privateClient"; - -/** - * Register a new user (company or individual). The user will receive an email with a verification link. - * @summary Register a new user (company or individual) - */ -export const apiAccountRegisterCreate = ( - userRegistration: UserRegistration, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/account/register/`, - method: "POST", - headers: { "Content-Type": "application/json" }, - data: userRegistration, - signal, - }); -}; - -export const getApiAccountRegisterCreateMutationOptions = < - TError = void, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: UserRegistration }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { data: UserRegistration }, - TContext -> => { - const mutationKey = ["apiAccountRegisterCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { data: UserRegistration } - > = (props) => { - const { data } = props ?? {}; - - return apiAccountRegisterCreate(data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiAccountRegisterCreateMutationResult = NonNullable< - Awaited> ->; -export type ApiAccountRegisterCreateMutationBody = UserRegistration; -export type ApiAccountRegisterCreateMutationError = void; - -/** - * @summary Register a new user (company or individual) - */ -export const useApiAccountRegisterCreate = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: UserRegistration }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: UserRegistration }, - TContext -> => { - const mutationOptions = getApiAccountRegisterCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * Verify user email using the link with uid and token. - * @summary Verify user email via link - */ -export const apiAccountVerifyEmailRetrieve = ( - uidb64: string, - token: string, - signal?: AbortSignal, -) => { - return privateMutator({ - url: `/api/account/verify-email/${uidb64}/${token}/`, - method: "GET", - signal, - }); -}; - -export const getApiAccountVerifyEmailRetrieveQueryKey = ( - uidb64?: string, - token?: string, -) => { - return [`/api/account/verify-email/${uidb64}/${token}/`] as const; -}; - -export const getApiAccountVerifyEmailRetrieveQueryOptions = < - TData = Awaited>, - TError = void, ->( - uidb64: string, - token: string, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, -) => { - const { query: queryOptions } = options ?? {}; - - const queryKey = - queryOptions?.queryKey ?? - getApiAccountVerifyEmailRetrieveQueryKey(uidb64, token); - - const queryFn: QueryFunction< - Awaited> - > = ({ signal }) => apiAccountVerifyEmailRetrieve(uidb64, token, signal); - - return { - queryKey, - queryFn, - enabled: !!(uidb64 && token), - ...queryOptions, - } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag }; -}; - -export type ApiAccountVerifyEmailRetrieveQueryResult = NonNullable< - Awaited> ->; -export type ApiAccountVerifyEmailRetrieveQueryError = void; - -export function useApiAccountVerifyEmailRetrieve< - TData = Awaited>, - TError = void, ->( - uidb64: string, - token: string, - options: { - query: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { - queryKey: DataTag; -}; -export function useApiAccountVerifyEmailRetrieve< - TData = Awaited>, - TError = void, ->( - uidb64: string, - token: string, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - "initialData" - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -export function useApiAccountVerifyEmailRetrieve< - TData = Awaited>, - TError = void, ->( - uidb64: string, - token: string, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -}; -/** - * @summary Verify user email via link - */ - -export function useApiAccountVerifyEmailRetrieve< - TData = Awaited>, - TError = void, ->( - uidb64: string, - token: string, - options?: { - query?: Partial< - UseQueryOptions< - Awaited>, - TError, - TData - > - >; - }, - queryClient?: QueryClient, -): UseQueryResult & { - queryKey: DataTag; -} { - const queryOptions = getApiAccountVerifyEmailRetrieveQueryOptions( - uidb64, - token, - options, - ); - - const query = useQuery(queryOptions, queryClient) as UseQueryResult< - TData, - TError - > & { queryKey: DataTag }; - - query.queryKey = queryOptions.queryKey; - - return query; -} diff --git a/frontend/src/api/generated/private/packet/packet.ts b/frontend/src/api/generated/private/zasilkovna/zasilkovna.ts similarity index 68% rename from frontend/src/api/generated/private/packet/packet.ts rename to frontend/src/api/generated/private/zasilkovna/zasilkovna.ts index b790f14..3d2a1e0 100644 --- a/frontend/src/api/generated/private/packet/packet.ts +++ b/frontend/src/api/generated/private/zasilkovna/zasilkovna.ts @@ -19,7 +19,13 @@ import type { UseQueryResult, } from "@tanstack/react-query"; -import type { TrackingURL, ZasilkovnaPacket } from ".././models"; +import type { + ApiZasilkovnaShipmentsListParams, + PaginatedZasilkovnaShipmentList, + TrackingURL, + ZasilkovnaPacket, + ZasilkovnaShipment, +} from ".././models"; import { privateMutator } from "../../../privateClient"; @@ -721,3 +727,335 @@ export function useApiZasilkovnaPacketsTrackingUrlRetrieve< return query; } + +/** + * Returns a paginated list of Packeta (Zásilkovna) shipments. + * @summary Hromadný shipment + */ +export const apiZasilkovnaShipmentsList = ( + params?: ApiZasilkovnaShipmentsListParams, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/zasilkovna/shipments/`, + method: "GET", + params, + signal, + }); +}; + +export const getApiZasilkovnaShipmentsListQueryKey = ( + params?: ApiZasilkovnaShipmentsListParams, +) => { + return [`/api/zasilkovna/shipments/`, ...(params ? [params] : [])] as const; +}; + +export const getApiZasilkovnaShipmentsListQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: ApiZasilkovnaShipmentsListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiZasilkovnaShipmentsListQueryKey(params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiZasilkovnaShipmentsList(params, signal); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiZasilkovnaShipmentsListQueryResult = NonNullable< + Awaited> +>; +export type ApiZasilkovnaShipmentsListQueryError = unknown; + +export function useApiZasilkovnaShipmentsList< + TData = Awaited>, + TError = unknown, +>( + params: undefined | ApiZasilkovnaShipmentsListParams, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiZasilkovnaShipmentsList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiZasilkovnaShipmentsListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiZasilkovnaShipmentsList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiZasilkovnaShipmentsListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Hromadný shipment + */ + +export function useApiZasilkovnaShipmentsList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiZasilkovnaShipmentsListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiZasilkovnaShipmentsListQueryOptions( + params, + options, + ); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * Returns detail for a single shipment. + * @summary Detail hromadné zásilky + */ +export const apiZasilkovnaShipmentsRetrieve = ( + id: number, + signal?: AbortSignal, +) => { + return privateMutator({ + url: `/api/zasilkovna/shipments/${id}/`, + method: "GET", + signal, + }); +}; + +export const getApiZasilkovnaShipmentsRetrieveQueryKey = (id?: number) => { + return [`/api/zasilkovna/shipments/${id}/`] as const; +}; + +export const getApiZasilkovnaShipmentsRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiZasilkovnaShipmentsRetrieveQueryKey(id); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiZasilkovnaShipmentsRetrieve(id, signal); + + return { + queryKey, + queryFn, + enabled: !!id, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiZasilkovnaShipmentsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type ApiZasilkovnaShipmentsRetrieveQueryError = unknown; + +export function useApiZasilkovnaShipmentsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiZasilkovnaShipmentsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiZasilkovnaShipmentsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Detail hromadné zásilky + */ + +export function useApiZasilkovnaShipmentsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiZasilkovnaShipmentsRetrieveQueryOptions( + id, + options, + ); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} diff --git a/frontend/src/api/generated/public/account.ts b/frontend/src/api/generated/public/account.ts new file mode 100644 index 0000000..fd2b7d8 --- /dev/null +++ b/frontend/src/api/generated/public/account.ts @@ -0,0 +1,706 @@ +/** + * Generated by orval v7.17.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.0 + */ +import { useMutation, useQuery } from "@tanstack/react-query"; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + MutationFunction, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseMutationOptions, + UseMutationResult, + UseQueryOptions, + UseQueryResult, +} from "@tanstack/react-query"; + +import type { + CustomTokenObtainPair, + PasswordResetConfirm, + PasswordResetRequest, + UserRegistration, +} from "./models"; + +import { publicMutator } from "../../publicClient"; + +/** + * Authenticate user and obtain JWT access and refresh tokens. You can use either email or username. + * @summary Obtain JWT access and refresh tokens (cookie-based) + */ +export const apiAccountLoginCreate = ( + customTokenObtainPair: CustomTokenObtainPair, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/account/login/`, + method: "POST", + headers: { "Content-Type": "application/json" }, + data: customTokenObtainPair, + signal, + }); +}; + +export const getApiAccountLoginCreateMutationOptions = < + TError = void, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CustomTokenObtainPair }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { data: CustomTokenObtainPair }, + TContext +> => { + const mutationKey = ["apiAccountLoginCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { data: CustomTokenObtainPair } + > = (props) => { + const { data } = props ?? {}; + + return apiAccountLoginCreate(data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiAccountLoginCreateMutationResult = NonNullable< + Awaited> +>; +export type ApiAccountLoginCreateMutationBody = CustomTokenObtainPair; +export type ApiAccountLoginCreateMutationError = void; + +/** + * @summary Obtain JWT access and refresh tokens (cookie-based) + */ +export const useApiAccountLoginCreate = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CustomTokenObtainPair }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: CustomTokenObtainPair }, + TContext +> => { + const mutationOptions = getApiAccountLoginCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * Logs out the user by deleting access and refresh token cookies. + * @summary Logout user (delete access and refresh token cookies) + */ +export const apiAccountLogoutCreate = (signal?: AbortSignal) => { + return publicMutator({ + url: `/api/account/logout/`, + method: "POST", + signal, + }); +}; + +export const getApiAccountLogoutCreateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + void, + TContext +> => { + const mutationKey = ["apiAccountLogoutCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + void + > = () => { + return apiAccountLogoutCreate(); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiAccountLogoutCreateMutationResult = NonNullable< + Awaited> +>; + +export type ApiAccountLogoutCreateMutationError = unknown; + +/** + * @summary Logout user (delete access and refresh token cookies) + */ +export const useApiAccountLogoutCreate = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + void, + TContext +> => { + const mutationOptions = getApiAccountLogoutCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * Request password reset by providing registered email. An email with instructions will be sent. + * @summary Request password reset (send email) + */ +export const apiAccountPasswordResetCreate = ( + passwordResetRequest: PasswordResetRequest, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/account/password-reset/`, + method: "POST", + headers: { "Content-Type": "application/json" }, + data: passwordResetRequest, + signal, + }); +}; + +export const getApiAccountPasswordResetCreateMutationOptions = < + TError = void, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: PasswordResetRequest }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { data: PasswordResetRequest }, + TContext +> => { + const mutationKey = ["apiAccountPasswordResetCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { data: PasswordResetRequest } + > = (props) => { + const { data } = props ?? {}; + + return apiAccountPasswordResetCreate(data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiAccountPasswordResetCreateMutationResult = NonNullable< + Awaited> +>; +export type ApiAccountPasswordResetCreateMutationBody = PasswordResetRequest; +export type ApiAccountPasswordResetCreateMutationError = void; + +/** + * @summary Request password reset (send email) + */ +export const useApiAccountPasswordResetCreate = < + TError = void, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: PasswordResetRequest }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: PasswordResetRequest }, + TContext +> => { + const mutationOptions = + getApiAccountPasswordResetCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * Confirm password reset using token from email. + * @summary Confirm password reset via token + */ +export const apiAccountPasswordResetConfirmCreate = ( + uidb64: string, + token: string, + passwordResetConfirm: PasswordResetConfirm, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/account/password-reset-confirm/${uidb64}/${token}/`, + method: "POST", + headers: { "Content-Type": "application/json" }, + data: passwordResetConfirm, + signal, + }); +}; + +export const getApiAccountPasswordResetConfirmCreateMutationOptions = < + TError = void, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidb64: string; token: string; data: PasswordResetConfirm }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { uidb64: string; token: string; data: PasswordResetConfirm }, + TContext +> => { + const mutationKey = ["apiAccountPasswordResetConfirmCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { uidb64: string; token: string; data: PasswordResetConfirm } + > = (props) => { + const { uidb64, token, data } = props ?? {}; + + return apiAccountPasswordResetConfirmCreate(uidb64, token, data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiAccountPasswordResetConfirmCreateMutationResult = NonNullable< + Awaited> +>; +export type ApiAccountPasswordResetConfirmCreateMutationBody = + PasswordResetConfirm; +export type ApiAccountPasswordResetConfirmCreateMutationError = void; + +/** + * @summary Confirm password reset via token + */ +export const useApiAccountPasswordResetConfirmCreate = < + TError = void, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidb64: string; token: string; data: PasswordResetConfirm }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { uidb64: string; token: string; data: PasswordResetConfirm }, + TContext +> => { + const mutationOptions = + getApiAccountPasswordResetConfirmCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * Register a new user (company or individual). The user will receive an email with a verification link. + * @summary Register a new user (company or individual) + */ +export const apiAccountRegisterCreate = ( + userRegistration: UserRegistration, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/account/register/`, + method: "POST", + headers: { "Content-Type": "application/json" }, + data: userRegistration, + signal, + }); +}; + +export const getApiAccountRegisterCreateMutationOptions = < + TError = void, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: UserRegistration }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { data: UserRegistration }, + TContext +> => { + const mutationKey = ["apiAccountRegisterCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { data: UserRegistration } + > = (props) => { + const { data } = props ?? {}; + + return apiAccountRegisterCreate(data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiAccountRegisterCreateMutationResult = NonNullable< + Awaited> +>; +export type ApiAccountRegisterCreateMutationBody = UserRegistration; +export type ApiAccountRegisterCreateMutationError = void; + +/** + * @summary Register a new user (company or individual) + */ +export const useApiAccountRegisterCreate = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: UserRegistration }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: UserRegistration }, + TContext +> => { + const mutationOptions = getApiAccountRegisterCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * Refresh JWT access and refresh tokens using the refresh token stored in cookie. + * @summary Refresh JWT token using cookie + */ +export const apiAccountTokenRefreshCreate = (signal?: AbortSignal) => { + return publicMutator({ + url: `/api/account/token/refresh/`, + method: "POST", + signal, + }); +}; + +export const getApiAccountTokenRefreshCreateMutationOptions = < + TError = void, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + void, + TContext +> => { + const mutationKey = ["apiAccountTokenRefreshCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + void + > = () => { + return apiAccountTokenRefreshCreate(); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiAccountTokenRefreshCreateMutationResult = NonNullable< + Awaited> +>; + +export type ApiAccountTokenRefreshCreateMutationError = void; + +/** + * @summary Refresh JWT token using cookie + */ +export const useApiAccountTokenRefreshCreate = < + TError = void, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + void, + TContext +> => { + const mutationOptions = + getApiAccountTokenRefreshCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * Verify user email using the link with uid and token. + * @summary Verify user email via link + */ +export const apiAccountVerifyEmailRetrieve = ( + uidb64: string, + token: string, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/account/verify-email/${uidb64}/${token}/`, + method: "GET", + signal, + }); +}; + +export const getApiAccountVerifyEmailRetrieveQueryKey = ( + uidb64?: string, + token?: string, +) => { + return [`/api/account/verify-email/${uidb64}/${token}/`] as const; +}; + +export const getApiAccountVerifyEmailRetrieveQueryOptions = < + TData = Awaited>, + TError = void, +>( + uidb64: string, + token: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? + getApiAccountVerifyEmailRetrieveQueryKey(uidb64, token); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiAccountVerifyEmailRetrieve(uidb64, token, signal); + + return { + queryKey, + queryFn, + enabled: !!(uidb64 && token), + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiAccountVerifyEmailRetrieveQueryResult = NonNullable< + Awaited> +>; +export type ApiAccountVerifyEmailRetrieveQueryError = void; + +export function useApiAccountVerifyEmailRetrieve< + TData = Awaited>, + TError = void, +>( + uidb64: string, + token: string, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiAccountVerifyEmailRetrieve< + TData = Awaited>, + TError = void, +>( + uidb64: string, + token: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiAccountVerifyEmailRetrieve< + TData = Awaited>, + TError = void, +>( + uidb64: string, + token: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Verify user email via link + */ + +export function useApiAccountVerifyEmailRetrieve< + TData = Awaited>, + TError = void, +>( + uidb64: string, + token: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiAccountVerifyEmailRetrieveQueryOptions( + uidb64, + token, + options, + ); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} diff --git a/frontend/src/api/generated/public/advertisement.ts b/frontend/src/api/generated/public/advertisement.ts new file mode 100644 index 0000000..b462adc --- /dev/null +++ b/frontend/src/api/generated/public/advertisement.ts @@ -0,0 +1,88 @@ +/** + * Generated by orval v7.17.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.0 + */ +import { useMutation } from "@tanstack/react-query"; +import type { + MutationFunction, + QueryClient, + UseMutationOptions, + UseMutationResult, +} from "@tanstack/react-query"; + +import { publicMutator } from "../../publicClient"; + +export const apiAdvertisementContactMeCreate = (signal?: AbortSignal) => { + return publicMutator({ + url: `/api/advertisement/contact-me/`, + method: "POST", + signal, + }); +}; + +export const getApiAdvertisementContactMeCreateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + void, + TContext +> => { + const mutationKey = ["apiAdvertisementContactMeCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + void + > = () => { + return apiAdvertisementContactMeCreate(); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiAdvertisementContactMeCreateMutationResult = NonNullable< + Awaited> +>; + +export type ApiAdvertisementContactMeCreateMutationError = unknown; + +export const useApiAdvertisementContactMeCreate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + void, + TContext +> => { + const mutationOptions = + getApiAdvertisementContactMeCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; diff --git a/frontend/src/api/generated/public/authentication.ts b/frontend/src/api/generated/public/authentication.ts deleted file mode 100644 index e8bc5ca..0000000 --- a/frontend/src/api/generated/public/authentication.ts +++ /dev/null @@ -1,256 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ -import { useMutation } from "@tanstack/react-query"; -import type { - MutationFunction, - QueryClient, - UseMutationOptions, - UseMutationResult, -} from "@tanstack/react-query"; - -import type { CustomTokenObtainPair } from "./models"; - -import { publicMutator } from "../../publicClient"; - -/** - * Authenticate user and obtain JWT access and refresh tokens. You can use either email or username. - * @summary Obtain JWT access and refresh tokens (cookie-based) - */ -export const apiAccountLoginCreate = ( - customTokenObtainPair: CustomTokenObtainPair, - signal?: AbortSignal, -) => { - return publicMutator({ - url: `/api/account/login/`, - method: "POST", - headers: { "Content-Type": "application/json" }, - data: customTokenObtainPair, - signal, - }); -}; - -export const getApiAccountLoginCreateMutationOptions = < - TError = void, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: CustomTokenObtainPair }, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - { data: CustomTokenObtainPair }, - TContext -> => { - const mutationKey = ["apiAccountLoginCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - { data: CustomTokenObtainPair } - > = (props) => { - const { data } = props ?? {}; - - return apiAccountLoginCreate(data); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiAccountLoginCreateMutationResult = NonNullable< - Awaited> ->; -export type ApiAccountLoginCreateMutationBody = CustomTokenObtainPair; -export type ApiAccountLoginCreateMutationError = void; - -/** - * @summary Obtain JWT access and refresh tokens (cookie-based) - */ -export const useApiAccountLoginCreate = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: CustomTokenObtainPair }, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: CustomTokenObtainPair }, - TContext -> => { - const mutationOptions = getApiAccountLoginCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * Logs out the user by deleting access and refresh token cookies. - * @summary Logout user (delete access and refresh token cookies) - */ -export const apiAccountLogoutCreate = (signal?: AbortSignal) => { - return publicMutator({ - url: `/api/account/logout/`, - method: "POST", - signal, - }); -}; - -export const getApiAccountLogoutCreateMutationOptions = < - TError = unknown, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - void, - TContext -> => { - const mutationKey = ["apiAccountLogoutCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - void - > = () => { - return apiAccountLogoutCreate(); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiAccountLogoutCreateMutationResult = NonNullable< - Awaited> ->; - -export type ApiAccountLogoutCreateMutationError = unknown; - -/** - * @summary Logout user (delete access and refresh token cookies) - */ -export const useApiAccountLogoutCreate = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - void, - TContext -> => { - const mutationOptions = getApiAccountLogoutCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; -/** - * Refresh JWT access and refresh tokens using the refresh token stored in cookie. - * @summary Refresh JWT token using cookie - */ -export const apiAccountTokenRefreshCreate = (signal?: AbortSignal) => { - return publicMutator({ - url: `/api/account/token/refresh/`, - method: "POST", - signal, - }); -}; - -export const getApiAccountTokenRefreshCreateMutationOptions = < - TError = void, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - >; -}): UseMutationOptions< - Awaited>, - TError, - void, - TContext -> => { - const mutationKey = ["apiAccountTokenRefreshCreate"]; - const { mutation: mutationOptions } = options - ? options.mutation && - "mutationKey" in options.mutation && - options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey } }; - - const mutationFn: MutationFunction< - Awaited>, - void - > = () => { - return apiAccountTokenRefreshCreate(); - }; - - return { mutationFn, ...mutationOptions }; -}; - -export type ApiAccountTokenRefreshCreateMutationResult = NonNullable< - Awaited> ->; - -export type ApiAccountTokenRefreshCreateMutationError = void; - -/** - * @summary Refresh JWT token using cookie - */ -export const useApiAccountTokenRefreshCreate = < - TError = void, - TContext = unknown, ->( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - >; - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - void, - TContext -> => { - const mutationOptions = - getApiAccountTokenRefreshCreateMutationOptions(options); - - return useMutation(mutationOptions, queryClient); -}; diff --git a/frontend/src/api/generated/public/commerce.ts b/frontend/src/api/generated/public/commerce.ts new file mode 100644 index 0000000..bc02f4f --- /dev/null +++ b/frontend/src/api/generated/public/commerce.ts @@ -0,0 +1,1767 @@ +/** + * Generated by orval v7.17.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.0 + */ +import { useMutation, useQuery } from "@tanstack/react-query"; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + MutationFunction, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseMutationOptions, + UseMutationResult, + UseQueryOptions, + UseQueryResult, +} from "@tanstack/react-query"; + +import type { + ApiCommerceCategoriesListParams, + ApiCommerceDiscountCodesListParams, + ApiCommerceOrdersListParams, + ApiCommerceProductImagesListParams, + ApiCommerceProductsListParams, + Category, + DiscountCode, + OrderCreate, + OrderRead, + PaginatedCategoryList, + PaginatedDiscountCodeList, + PaginatedOrderReadList, + PaginatedProductImageList, + PaginatedProductList, + Product, + ProductImage, +} from "./models"; + +import { publicMutator } from "../../publicClient"; + +/** + * @summary List categories (public) + */ +export const apiCommerceCategoriesList = ( + params?: ApiCommerceCategoriesListParams, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/commerce/categories/`, + method: "GET", + params, + signal, + }); +}; + +export const getApiCommerceCategoriesListQueryKey = ( + params?: ApiCommerceCategoriesListParams, +) => { + return [`/api/commerce/categories/`, ...(params ? [params] : [])] as const; +}; + +export const getApiCommerceCategoriesListQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceCategoriesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiCommerceCategoriesListQueryKey(params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiCommerceCategoriesList(params, signal); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiCommerceCategoriesListQueryResult = NonNullable< + Awaited> +>; +export type ApiCommerceCategoriesListQueryError = unknown; + +export function useApiCommerceCategoriesList< + TData = Awaited>, + TError = unknown, +>( + params: undefined | ApiCommerceCategoriesListParams, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceCategoriesList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceCategoriesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceCategoriesList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceCategoriesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary List categories (public) + */ + +export function useApiCommerceCategoriesList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceCategoriesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiCommerceCategoriesListQueryOptions( + params, + options, + ); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Retrieve category (public) + */ +export const apiCommerceCategoriesRetrieve = ( + id: number, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/commerce/categories/${id}/`, + method: "GET", + signal, + }); +}; + +export const getApiCommerceCategoriesRetrieveQueryKey = (id?: number) => { + return [`/api/commerce/categories/${id}/`] as const; +}; + +export const getApiCommerceCategoriesRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiCommerceCategoriesRetrieveQueryKey(id); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiCommerceCategoriesRetrieve(id, signal); + + return { + queryKey, + queryFn, + enabled: !!id, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiCommerceCategoriesRetrieveQueryResult = NonNullable< + Awaited> +>; +export type ApiCommerceCategoriesRetrieveQueryError = unknown; + +export function useApiCommerceCategoriesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceCategoriesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceCategoriesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Retrieve category (public) + */ + +export function useApiCommerceCategoriesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiCommerceCategoriesRetrieveQueryOptions( + id, + options, + ); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary List discount codes (public) + */ +export const apiCommerceDiscountCodesList = ( + params?: ApiCommerceDiscountCodesListParams, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/commerce/discount-codes/`, + method: "GET", + params, + signal, + }); +}; + +export const getApiCommerceDiscountCodesListQueryKey = ( + params?: ApiCommerceDiscountCodesListParams, +) => { + return [ + `/api/commerce/discount-codes/`, + ...(params ? [params] : []), + ] as const; +}; + +export const getApiCommerceDiscountCodesListQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceDiscountCodesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiCommerceDiscountCodesListQueryKey(params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiCommerceDiscountCodesList(params, signal); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiCommerceDiscountCodesListQueryResult = NonNullable< + Awaited> +>; +export type ApiCommerceDiscountCodesListQueryError = unknown; + +export function useApiCommerceDiscountCodesList< + TData = Awaited>, + TError = unknown, +>( + params: undefined | ApiCommerceDiscountCodesListParams, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceDiscountCodesList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceDiscountCodesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceDiscountCodesList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceDiscountCodesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary List discount codes (public) + */ + +export function useApiCommerceDiscountCodesList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceDiscountCodesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiCommerceDiscountCodesListQueryOptions( + params, + options, + ); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Retrieve discount code (public) + */ +export const apiCommerceDiscountCodesRetrieve = ( + id: number, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/commerce/discount-codes/${id}/`, + method: "GET", + signal, + }); +}; + +export const getApiCommerceDiscountCodesRetrieveQueryKey = (id?: number) => { + return [`/api/commerce/discount-codes/${id}/`] as const; +}; + +export const getApiCommerceDiscountCodesRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiCommerceDiscountCodesRetrieveQueryKey(id); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiCommerceDiscountCodesRetrieve(id, signal); + + return { + queryKey, + queryFn, + enabled: !!id, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiCommerceDiscountCodesRetrieveQueryResult = NonNullable< + Awaited> +>; +export type ApiCommerceDiscountCodesRetrieveQueryError = unknown; + +export function useApiCommerceDiscountCodesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceDiscountCodesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceDiscountCodesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Retrieve discount code (public) + */ + +export function useApiCommerceDiscountCodesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiCommerceDiscountCodesRetrieveQueryOptions( + id, + options, + ); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary List Orders (public) + */ +export const apiCommerceOrdersList = ( + params?: ApiCommerceOrdersListParams, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/commerce/orders/`, + method: "GET", + params, + signal, + }); +}; + +export const getApiCommerceOrdersListQueryKey = ( + params?: ApiCommerceOrdersListParams, +) => { + return [`/api/commerce/orders/`, ...(params ? [params] : [])] as const; +}; + +export const getApiCommerceOrdersListQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceOrdersListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiCommerceOrdersListQueryKey(params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiCommerceOrdersList(params, signal); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiCommerceOrdersListQueryResult = NonNullable< + Awaited> +>; +export type ApiCommerceOrdersListQueryError = unknown; + +export function useApiCommerceOrdersList< + TData = Awaited>, + TError = unknown, +>( + params: undefined | ApiCommerceOrdersListParams, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceOrdersList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceOrdersListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceOrdersList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceOrdersListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary List Orders (public) + */ + +export function useApiCommerceOrdersList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceOrdersListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiCommerceOrdersListQueryOptions(params, options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Create Order (public) + */ +export const apiCommerceOrdersCreate = ( + orderCreate: OrderCreate, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/commerce/orders/`, + method: "POST", + headers: { "Content-Type": "application/json" }, + data: orderCreate, + signal, + }); +}; + +export const getApiCommerceOrdersCreateMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: OrderCreate }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { data: OrderCreate }, + TContext +> => { + const mutationKey = ["apiCommerceOrdersCreate"]; + const { mutation: mutationOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey } }; + + const mutationFn: MutationFunction< + Awaited>, + { data: OrderCreate } + > = (props) => { + const { data } = props ?? {}; + + return apiCommerceOrdersCreate(data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type ApiCommerceOrdersCreateMutationResult = NonNullable< + Awaited> +>; +export type ApiCommerceOrdersCreateMutationBody = OrderCreate; +export type ApiCommerceOrdersCreateMutationError = unknown; + +/** + * @summary Create Order (public) + */ +export const useApiCommerceOrdersCreate = < + TError = unknown, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: OrderCreate }, + TContext + >; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: OrderCreate }, + TContext +> => { + const mutationOptions = getApiCommerceOrdersCreateMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; +/** + * @summary Retrieve Order (public) + */ +export const apiCommerceOrdersRetrieve = (id: number, signal?: AbortSignal) => { + return publicMutator({ + url: `/api/commerce/orders/${id}/`, + method: "GET", + signal, + }); +}; + +export const getApiCommerceOrdersRetrieveQueryKey = (id?: number) => { + return [`/api/commerce/orders/${id}/`] as const; +}; + +export const getApiCommerceOrdersRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiCommerceOrdersRetrieveQueryKey(id); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiCommerceOrdersRetrieve(id, signal); + + return { + queryKey, + queryFn, + enabled: !!id, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiCommerceOrdersRetrieveQueryResult = NonNullable< + Awaited> +>; +export type ApiCommerceOrdersRetrieveQueryError = unknown; + +export function useApiCommerceOrdersRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceOrdersRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceOrdersRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Retrieve Order (public) + */ + +export function useApiCommerceOrdersRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiCommerceOrdersRetrieveQueryOptions(id, options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary List product images (public) + */ +export const apiCommerceProductImagesList = ( + params?: ApiCommerceProductImagesListParams, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/commerce/product-images/`, + method: "GET", + params, + signal, + }); +}; + +export const getApiCommerceProductImagesListQueryKey = ( + params?: ApiCommerceProductImagesListParams, +) => { + return [ + `/api/commerce/product-images/`, + ...(params ? [params] : []), + ] as const; +}; + +export const getApiCommerceProductImagesListQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceProductImagesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiCommerceProductImagesListQueryKey(params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiCommerceProductImagesList(params, signal); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiCommerceProductImagesListQueryResult = NonNullable< + Awaited> +>; +export type ApiCommerceProductImagesListQueryError = unknown; + +export function useApiCommerceProductImagesList< + TData = Awaited>, + TError = unknown, +>( + params: undefined | ApiCommerceProductImagesListParams, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceProductImagesList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceProductImagesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceProductImagesList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceProductImagesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary List product images (public) + */ + +export function useApiCommerceProductImagesList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceProductImagesListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiCommerceProductImagesListQueryOptions( + params, + options, + ); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Retrieve product image (public) + */ +export const apiCommerceProductImagesRetrieve = ( + id: number, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/commerce/product-images/${id}/`, + method: "GET", + signal, + }); +}; + +export const getApiCommerceProductImagesRetrieveQueryKey = (id?: number) => { + return [`/api/commerce/product-images/${id}/`] as const; +}; + +export const getApiCommerceProductImagesRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiCommerceProductImagesRetrieveQueryKey(id); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiCommerceProductImagesRetrieve(id, signal); + + return { + queryKey, + queryFn, + enabled: !!id, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiCommerceProductImagesRetrieveQueryResult = NonNullable< + Awaited> +>; +export type ApiCommerceProductImagesRetrieveQueryError = unknown; + +export function useApiCommerceProductImagesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceProductImagesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceProductImagesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Retrieve product image (public) + */ + +export function useApiCommerceProductImagesRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiCommerceProductImagesRetrieveQueryOptions( + id, + options, + ); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary List products (public) + */ +export const apiCommerceProductsList = ( + params?: ApiCommerceProductsListParams, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/commerce/products/`, + method: "GET", + params, + signal, + }); +}; + +export const getApiCommerceProductsListQueryKey = ( + params?: ApiCommerceProductsListParams, +) => { + return [`/api/commerce/products/`, ...(params ? [params] : [])] as const; +}; + +export const getApiCommerceProductsListQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceProductsListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiCommerceProductsListQueryKey(params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiCommerceProductsList(params, signal); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiCommerceProductsListQueryResult = NonNullable< + Awaited> +>; +export type ApiCommerceProductsListQueryError = unknown; + +export function useApiCommerceProductsList< + TData = Awaited>, + TError = unknown, +>( + params: undefined | ApiCommerceProductsListParams, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceProductsList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceProductsListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceProductsList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceProductsListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary List products (public) + */ + +export function useApiCommerceProductsList< + TData = Awaited>, + TError = unknown, +>( + params?: ApiCommerceProductsListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiCommerceProductsListQueryOptions(params, options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Retrieve product (public) + */ +export const apiCommerceProductsRetrieve = ( + id: number, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/commerce/products/${id}/`, + method: "GET", + signal, + }); +}; + +export const getApiCommerceProductsRetrieveQueryKey = (id?: number) => { + return [`/api/commerce/products/${id}/`] as const; +}; + +export const getApiCommerceProductsRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getApiCommerceProductsRetrieveQueryKey(id); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => apiCommerceProductsRetrieve(id, signal); + + return { + queryKey, + queryFn, + enabled: !!id, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiCommerceProductsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type ApiCommerceProductsRetrieveQueryError = unknown; + +export function useApiCommerceProductsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceProductsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiCommerceProductsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Retrieve product (public) + */ + +export function useApiCommerceProductsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getApiCommerceProductsRetrieveQueryOptions(id, options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} diff --git a/frontend/src/api/generated/public/configuration.ts b/frontend/src/api/generated/public/configuration.ts new file mode 100644 index 0000000..7bb424d --- /dev/null +++ b/frontend/src/api/generated/public/configuration.ts @@ -0,0 +1,408 @@ +/** + * Generated by orval v7.17.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.0 + */ +import { useQuery } from "@tanstack/react-query"; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseQueryOptions, + UseQueryResult, +} from "@tanstack/react-query"; + +import type { + ApiConfigurationPublicShopConfigurationListParams, + PaginatedSiteConfigurationPublicList, + SiteConfigurationPublic, +} from "./models"; + +import { publicMutator } from "../../publicClient"; + +/** + * @summary List site configuration (public) + */ +export const apiConfigurationPublicShopConfigurationList = ( + params?: ApiConfigurationPublicShopConfigurationListParams, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/configuration/public/shop-configuration/`, + method: "GET", + params, + signal, + }); +}; + +export const getApiConfigurationPublicShopConfigurationListQueryKey = ( + params?: ApiConfigurationPublicShopConfigurationListParams, +) => { + return [ + `/api/configuration/public/shop-configuration/`, + ...(params ? [params] : []), + ] as const; +}; + +export const getApiConfigurationPublicShopConfigurationListQueryOptions = < + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + params?: ApiConfigurationPublicShopConfigurationListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? + getApiConfigurationPublicShopConfigurationListQueryKey(params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => + apiConfigurationPublicShopConfigurationList(params, signal); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiConfigurationPublicShopConfigurationListQueryResult = + NonNullable< + Awaited> + >; +export type ApiConfigurationPublicShopConfigurationListQueryError = unknown; + +export function useApiConfigurationPublicShopConfigurationList< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + params: undefined | ApiConfigurationPublicShopConfigurationListParams, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited< + ReturnType + >, + TError, + Awaited< + ReturnType + > + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiConfigurationPublicShopConfigurationList< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + params?: ApiConfigurationPublicShopConfigurationListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited< + ReturnType + >, + TError, + Awaited< + ReturnType + > + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiConfigurationPublicShopConfigurationList< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + params?: ApiConfigurationPublicShopConfigurationListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary List site configuration (public) + */ + +export function useApiConfigurationPublicShopConfigurationList< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + params?: ApiConfigurationPublicShopConfigurationListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = + getApiConfigurationPublicShopConfigurationListQueryOptions(params, options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Retrieve site configuration (public) + */ +export const apiConfigurationPublicShopConfigurationRetrieve = ( + id: number, + signal?: AbortSignal, +) => { + return publicMutator({ + url: `/api/configuration/public/shop-configuration/${id}/`, + method: "GET", + signal, + }); +}; + +export const getApiConfigurationPublicShopConfigurationRetrieveQueryKey = ( + id?: number, +) => { + return [`/api/configuration/public/shop-configuration/${id}/`] as const; +}; + +export const getApiConfigurationPublicShopConfigurationRetrieveQueryOptions = < + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > + >; + }, +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? + getApiConfigurationPublicShopConfigurationRetrieveQueryKey(id); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => + apiConfigurationPublicShopConfigurationRetrieve(id, signal); + + return { + queryKey, + queryFn, + enabled: !!id, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ApiConfigurationPublicShopConfigurationRetrieveQueryResult = + NonNullable< + Awaited> + >; +export type ApiConfigurationPublicShopConfigurationRetrieveQueryError = unknown; + +export function useApiConfigurationPublicShopConfigurationRetrieve< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + id: number, + options: { + query: Partial< + UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited< + ReturnType + >, + TError, + Awaited< + ReturnType + > + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useApiConfigurationPublicShopConfigurationRetrieve< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited< + ReturnType + >, + TError, + Awaited< + ReturnType + > + >, + "initialData" + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useApiConfigurationPublicShopConfigurationRetrieve< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Retrieve site configuration (public) + */ + +export function useApiConfigurationPublicShopConfigurationRetrieve< + TData = Awaited< + ReturnType + >, + TError = unknown, +>( + id: number, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > + >; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = + getApiConfigurationPublicShopConfigurationRetrieveQueryOptions(id, options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} diff --git a/frontend/src/api/generated/public/downloader.ts b/frontend/src/api/generated/public/downloader.ts index 9773093..054fc93 100644 --- a/frontend/src/api/generated/public/downloader.ts +++ b/frontend/src/api/generated/public/downloader.ts @@ -31,6 +31,21 @@ import type { import { publicMutator } from "../../publicClient"; /** + * + Fetch detailed information about a video from supported platforms. + + **Supported platforms:** YouTube, TikTok, Vimeo, Twitter, Instagram, Facebook, Reddit, and many more. + + **Returns:** + - Video title, duration, and thumbnail + - Available video qualities/resolutions + - Available audio formats + + **Usage:** + ``` + GET /api/downloader/download/?url=https://youtube.com/watch?v=VIDEO_ID + ``` + * @summary Get video info from URL */ export const apiDownloaderDownloadRetrieve = ( @@ -195,6 +210,29 @@ export function useApiDownloaderDownloadRetrieve< } /** + * + Download video with optional quality constraints and container format conversion. + + **Quality Parameters (optional):** + - If not specified, yt-dlp will automatically select the best available quality. + - `video_quality`: Maximum video height in pixels (e.g., 1080, 720, 480). + - `audio_quality`: Maximum audio bitrate in kbps (e.g., 320, 192, 128). + + **Format/Extension:** + - Any format supported by ffmpeg (mp4, mkv, webm, avi, mov, flv, m4a, mp3, etc.). + - Defaults to 'mp4' if not specified. + - The conversion is handled automatically by ffmpeg in the background. + + **Advanced Options:** + - `subtitles`: Download subtitles (language codes like 'en,cs' or 'all') + - `embed_subtitles`: Embed subtitles into video file + - `embed_thumbnail`: Embed thumbnail as cover art + - `extract_audio`: Extract audio only (ignores video quality) + - `start_time`: Trim start (format: HH:MM:SS or seconds) + - `end_time`: Trim end (format: HH:MM:SS or seconds) + - `playlist_items`: Download specific playlist items (e.g., '1-5,8,10') + - `cookies`: Browser cookies for age-restricted content (Netscape format) + * @summary Download video from URL */ export const apiDownloaderDownloadCreate = ( diff --git a/frontend/src/api/generated/private/models/apiCommerceCategoriesListParams.ts b/frontend/src/api/generated/public/models/apiCommerceCategoriesListParams.ts similarity index 100% rename from frontend/src/api/generated/private/models/apiCommerceCategoriesListParams.ts rename to frontend/src/api/generated/public/models/apiCommerceCategoriesListParams.ts diff --git a/frontend/src/api/generated/private/models/apiCommerceDiscountCodesListParams.ts b/frontend/src/api/generated/public/models/apiCommerceDiscountCodesListParams.ts similarity index 100% rename from frontend/src/api/generated/private/models/apiCommerceDiscountCodesListParams.ts rename to frontend/src/api/generated/public/models/apiCommerceDiscountCodesListParams.ts diff --git a/frontend/src/api/generated/private/models/apiCommerceOrdersListParams.ts b/frontend/src/api/generated/public/models/apiCommerceOrdersListParams.ts similarity index 100% rename from frontend/src/api/generated/private/models/apiCommerceOrdersListParams.ts rename to frontend/src/api/generated/public/models/apiCommerceOrdersListParams.ts diff --git a/frontend/src/api/generated/private/models/apiCommerceProductImagesListParams.ts b/frontend/src/api/generated/public/models/apiCommerceProductImagesListParams.ts similarity index 100% rename from frontend/src/api/generated/private/models/apiCommerceProductImagesListParams.ts rename to frontend/src/api/generated/public/models/apiCommerceProductImagesListParams.ts diff --git a/frontend/src/api/generated/private/models/apiCommerceProductsListParams.ts b/frontend/src/api/generated/public/models/apiCommerceProductsListParams.ts similarity index 100% rename from frontend/src/api/generated/private/models/apiCommerceProductsListParams.ts rename to frontend/src/api/generated/public/models/apiCommerceProductsListParams.ts diff --git a/frontend/src/api/generated/private/models/apiConfigurationPublicShopConfigurationListParams.ts b/frontend/src/api/generated/public/models/apiConfigurationPublicShopConfigurationListParams.ts similarity index 100% rename from frontend/src/api/generated/private/models/apiConfigurationPublicShopConfigurationListParams.ts rename to frontend/src/api/generated/public/models/apiConfigurationPublicShopConfigurationListParams.ts diff --git a/frontend/src/api/generated/public/models/apiDownloaderDownloadRetrieveParams.ts b/frontend/src/api/generated/public/models/apiDownloaderDownloadRetrieveParams.ts index e018fd3..5c520ce 100644 --- a/frontend/src/api/generated/public/models/apiDownloaderDownloadRetrieveParams.ts +++ b/frontend/src/api/generated/public/models/apiDownloaderDownloadRetrieveParams.ts @@ -6,7 +6,7 @@ export type ApiDownloaderDownloadRetrieveParams = { /** - * Video URL to analyze + * Video URL from YouTube, TikTok, Vimeo, etc. Must be a valid URL from a supported platform. * @minLength 1 */ url: string; diff --git a/frontend/src/api/generated/public/models/downloadErrorResponse.ts b/frontend/src/api/generated/public/models/downloadErrorResponse.ts index 036a310..8724fdb 100644 --- a/frontend/src/api/generated/public/models/downloadErrorResponse.ts +++ b/frontend/src/api/generated/public/models/downloadErrorResponse.ts @@ -6,5 +6,4 @@ export interface DownloadErrorResponse { error: string; - allowed?: string[]; } diff --git a/frontend/src/api/generated/public/models/downloadRequest.ts b/frontend/src/api/generated/public/models/downloadRequest.ts index 0193507..dd61b6f 100644 --- a/frontend/src/api/generated/public/models/downloadRequest.ts +++ b/frontend/src/api/generated/public/models/downloadRequest.ts @@ -3,34 +3,51 @@ * Do not edit manually. * OpenAPI spec version: 0.0.0 */ -import type { ExtEnum } from "./extEnum"; -import type { FormatEnum } from "./formatEnum"; export interface DownloadRequest { - /** Video URL to download */ + /** Video URL to download from supported platforms */ url: string; - /** Choose container format: mp4 (H.264 + AAC, most compatible), mkv (flexible, lossless container), webm (VP9/AV1 + Opus), flv (legacy), mov (Apple-friendly), avi (older), ogg (mostly obsolete). - -* `mp4` - mp4 -* `mkv` - mkv -* `webm` - webm -* `flv` - flv -* `mov` - mov -* `avi` - avi -* `ogg` - ogg */ - ext?: ExtEnum; - /** Alias of 'ext' (deprecated). - -* `mp4` - mp4 -* `mkv` - mkv -* `webm` - webm -* `flv` - flv -* `mov` - mov -* `avi` - avi -* `ogg` - ogg */ - format?: FormatEnum; - /** Target max video height (e.g. 1080). */ - video_quality: number; - /** Target max audio bitrate in kbps (e.g. 160). */ - audio_quality: number; + /** Container format for the output file. Common formats: mp4 (H.264 + AAC, most compatible), mkv (flexible, lossless container), webm (VP9/AV1 + Opus), flv (legacy), mov (Apple-friendly), avi (older), ogg, m4a (audio only), mp3 (audio only). The extension will be validated by ffmpeg during conversion. */ + ext?: string; + /** + * Optional: Target max video height in pixels (e.g. 1080, 720). If omitted, best quality is selected. + * @nullable + */ + video_quality?: number | null; + /** + * Optional: Target max audio bitrate in kbps (e.g. 320, 192, 128). If omitted, best quality is selected. + * @nullable + */ + audio_quality?: number | null; + /** + * Language codes (e.g., 'en', 'cs', 'en,cs') or 'all' for all available subtitles + * @nullable + */ + subtitles?: string | null; + /** Embed subtitles into the video file (requires mkv or mp4 container) */ + embed_subtitles?: boolean; + /** Embed thumbnail as cover art in the file */ + embed_thumbnail?: boolean; + /** Extract audio only, ignoring video quality settings */ + extract_audio?: boolean; + /** + * Start time for trimming (format: HH:MM:SS or seconds as integer) + * @nullable + */ + start_time?: string | null; + /** + * End time for trimming (format: HH:MM:SS or seconds as integer) + * @nullable + */ + end_time?: string | null; + /** + * Playlist items to download (e.g., '1-5,8,10' or '1,2,3') + * @nullable + */ + playlist_items?: string | null; + /** + * Browser cookies in Netscape format for age-restricted content. Export from browser extensions like 'Get cookies.txt' + * @nullable + */ + cookies?: string | null; } diff --git a/frontend/src/api/generated/public/models/errorResponse.ts b/frontend/src/api/generated/public/models/errorResponse.ts index fc2b666..2647109 100644 --- a/frontend/src/api/generated/public/models/errorResponse.ts +++ b/frontend/src/api/generated/public/models/errorResponse.ts @@ -5,5 +5,6 @@ */ export interface ErrorResponse { + /** Error message describing what went wrong */ error: string; } diff --git a/frontend/src/api/generated/public/models/extEnum.ts b/frontend/src/api/generated/public/models/extEnum.ts deleted file mode 100644 index f4ed4f6..0000000 --- a/frontend/src/api/generated/public/models/extEnum.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ - -/** - * * `mp4` - mp4 - * `mkv` - mkv - * `webm` - webm - * `flv` - flv - * `mov` - mov - * `avi` - avi - * `ogg` - ogg - */ -export type ExtEnum = (typeof ExtEnum)[keyof typeof ExtEnum]; - -// eslint-disable-next-line @typescript-eslint/no-redeclare -export const ExtEnum = { - mp4: "mp4", - mkv: "mkv", - webm: "webm", - flv: "flv", - mov: "mov", - avi: "avi", - ogg: "ogg", -} as const; diff --git a/frontend/src/api/generated/public/models/formatEnum.ts b/frontend/src/api/generated/public/models/formatEnum.ts deleted file mode 100644 index aefaf77..0000000 --- a/frontend/src/api/generated/public/models/formatEnum.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.0 - */ - -/** - * * `mp4` - mp4 - * `mkv` - mkv - * `webm` - webm - * `flv` - flv - * `mov` - mov - * `avi` - avi - * `ogg` - ogg - */ -export type FormatEnum = (typeof FormatEnum)[keyof typeof FormatEnum]; - -// eslint-disable-next-line @typescript-eslint/no-redeclare -export const FormatEnum = { - mp4: "mp4", - mkv: "mkv", - webm: "webm", - flv: "flv", - mov: "mov", - avi: "avi", - ogg: "ogg", -} as const; diff --git a/frontend/src/api/generated/public/models/index.ts b/frontend/src/api/generated/public/models/index.ts index c270709..70c8331 100644 --- a/frontend/src/api/generated/public/models/index.ts +++ b/frontend/src/api/generated/public/models/index.ts @@ -8,6 +8,12 @@ export * from "./additionalParam"; export * from "./apiChoicesRetrieve200"; export * from "./apiChoicesRetrieve200Item"; export * from "./apiChoicesRetrieveParams"; +export * from "./apiCommerceCategoriesListParams"; +export * from "./apiCommerceDiscountCodesListParams"; +export * from "./apiCommerceOrdersListParams"; +export * from "./apiCommerceProductImagesListParams"; +export * from "./apiCommerceProductsListParams"; +export * from "./apiConfigurationPublicShopConfigurationListParams"; export * from "./apiDownloaderDownloadRetrieveParams"; export * from "./callback"; export * from "./carrierRead"; @@ -22,8 +28,6 @@ export * from "./downloadErrorResponse"; export * from "./downloadRequest"; export * from "./downloaderStats"; export * from "./errorResponse"; -export * from "./extEnum"; -export * from "./formatEnum"; export * from "./item"; export * from "./orderCarrier"; export * from "./orderCreate"; diff --git a/frontend/src/api/generated/public/models/videoInfoResponse.ts b/frontend/src/api/generated/public/models/videoInfoResponse.ts index 9858144..e23e8b1 100644 --- a/frontend/src/api/generated/public/models/videoInfoResponse.ts +++ b/frontend/src/api/generated/public/models/videoInfoResponse.ts @@ -5,11 +5,20 @@ */ export interface VideoInfoResponse { + /** Video title */ title: string; - /** @nullable */ + /** + * Video duration in seconds (null if unavailable) + * @nullable + */ duration: number | null; - /** @nullable */ + /** + * URL to video thumbnail image + * @nullable + */ thumbnail: string | null; + /** List of available video quality options (e.g., '1080p', '720p', '480p') */ video_resolutions: string[]; + /** List of available audio format options */ audio_resolutions: string[]; } diff --git a/frontend/src/api/privateClient.ts b/frontend/src/api/privateClient.ts index 7b44d2b..a300a26 100644 --- a/frontend/src/api/privateClient.ts +++ b/frontend/src/api/privateClient.ts @@ -1,14 +1,18 @@ import axios, { type AxiosRequestConfig } from "axios"; -const backendUrl = import.meta.env.VITE_BACKEND_URL || "http://localhost:8000"; - - // použij tohle pro API vyžadující autentizaci export const privateApi = axios.create({ - baseURL: backendUrl, withCredentials: true, // potřebuje HttpOnly cookies }); +// Set baseURL at runtime (using Function to hide from orval's esbuild) +try { + const getEnv = new Function('return import.meta.env.VITE_BACKEND_URL'); + privateApi.defaults.baseURL = getEnv() || "http://localhost:8000"; +} catch { + privateApi.defaults.baseURL = "http://localhost:8000"; +} + privateApi.interceptors.response.use( (res) => res, async (error) => { diff --git a/frontend/src/api/publicClient.ts b/frontend/src/api/publicClient.ts index 52911ca..87175de 100644 --- a/frontend/src/api/publicClient.ts +++ b/frontend/src/api/publicClient.ts @@ -1,14 +1,18 @@ import axios, { type AxiosRequestConfig } from "axios"; -const backendUrl = import.meta.env.VITE_BACKEND_URL || "http://localhost:8000"; - - // použij tohle pro veřejné API nevyžadující autentizaci export const publicApi = axios.create({ - baseURL: backendUrl, withCredentials: false, // veřejné API NEPOSÍLÁ cookies }); +// Set baseURL at runtime (using Function to hide from orval's esbuild) +try { + const getEnv = new Function('return import.meta.env.VITE_BACKEND_URL'); + publicApi.defaults.baseURL = getEnv() || "http://localhost:8000"; +} catch { + publicApi.defaults.baseURL = "http://localhost:8000"; +} + // ⬇⬇⬇ TOHLE JE TEN MUTATOR ⬇⬇⬇ export const publicMutator = async ( diff --git a/frontend/src/orval.config.ts b/frontend/src/orval.config.ts index 76884f7..58c26fd 100644 --- a/frontend/src/orval.config.ts +++ b/frontend/src/orval.config.ts @@ -1,6 +1,6 @@ import { defineConfig } from "orval"; -const backendUrl = import.meta.env.VITE_BACKEND_URL || "http://localhost:8000"; +const backendUrl = process.env.VITE_BACKEND_URL || "http://localhost:8000"; // může se hodit pokud nechceme při buildu generovat klienta (nechat false pro produkci nebo vynechat) const SKIP_ORVAL = process.env.SKIP_ORVAL === "true"; @@ -27,6 +27,7 @@ export default defineConfig({ clean: true, client: "react-query", httpClient: "axios", + tsconfig: "./tsconfig.app.json", override: { mutator: { path: "api/publicClient.ts", @@ -57,6 +58,7 @@ export default defineConfig({ clean: true, client: "react-query", httpClient: "axios", + tsconfig: "./tsconfig.app.json", override: { mutator: { path: "api/privateClient.ts", diff --git a/frontend/src/pages/downloader/Downloader.tsx b/frontend/src/pages/downloader/Downloader.tsx index 9ca32ea..6eed859 100644 --- a/frontend/src/pages/downloader/Downloader.tsx +++ b/frontend/src/pages/downloader/Downloader.tsx @@ -2,16 +2,46 @@ import { useState } from 'react'; import { apiDownloaderDownloadRetrieve, apiDownloaderDownloadCreate } from '@/api/generated/public/downloader'; import { type VideoInfoResponse } from '@/api/generated/public/models'; +// Common file extensions supported by ffmpeg +const FILE_EXTENSIONS = [ + { value: 'mp4', label: 'MP4 (H.264 + AAC, most compatible)' }, + { value: 'mkv', label: 'MKV (Flexible, lossless container)' }, + { value: 'webm', label: 'WebM (VP9/AV1 + Opus)' }, + { value: 'avi', label: 'AVI (Older format)' }, + { value: 'mov', label: 'MOV (Apple-friendly)' }, + { value: 'flv', label: 'FLV (Legacy)' }, + { value: 'm4a', label: 'M4A (Audio only, AAC)' }, + { value: 'mp3', label: 'MP3 (Audio only)' }, + { value: 'ogg', label: 'OGG (Audio/Video)' }, +]; export default function Downloader() { const [videoUrl, setVideoUrl] = useState(''); const [videoInfo, setVideoInfo] = useState(null); const [isLoading, setIsLoading] = useState(false); + const [isDownloading, setIsDownloading] = useState(false); const [error, setError] = useState(null); - async function retriveVideoInfo() { + // Basic download options + const [selectedVideoQuality, setSelectedVideoQuality] = useState(''); + const [selectedAudioQuality, setSelectedAudioQuality] = useState(''); + const [selectedExtension, setSelectedExtension] = useState('mp4'); + + // Advanced options + const [subtitles, setSubtitles] = useState(''); + const [embedSubtitles, setEmbedSubtitles] = useState(false); + const [embedThumbnail, setEmbedThumbnail] = useState(false); + const [extractAudio, setExtractAudio] = useState(false); + const [startTime, setStartTime] = useState(''); + const [endTime, setEndTime] = useState(''); + const [playlistItems, setPlaylistItems] = useState(''); + const [cookies, setCookies] = useState(''); + const [showAdvanced, setShowAdvanced] = useState(false); + + async function retrieveVideoInfo() { setIsLoading(true); setError(null); + setVideoInfo(null); try { const info = await apiDownloaderDownloadRetrieve({ url: videoUrl }); setVideoInfo(info); @@ -20,52 +50,295 @@ export default function Downloader() { } finally { setIsLoading(false); } - - console.log('Retrieving video info for URL:', videoUrl); - console.log('Retrieved video info:', videoInfo); - } + async function handleDownload() { + if (!videoUrl) { + setError({ error: 'Please enter a URL first' }); + return; + } + + setIsDownloading(true); + setError(null); + + try { + // Parse quality values (remove 'p' and 'kbps' suffixes) + const videoQuality = selectedVideoQuality + ? parseInt(selectedVideoQuality.replace('p', '')) + : undefined; + const audioQuality = selectedAudioQuality + ? parseInt(selectedAudioQuality.replace('kbps', '')) + : undefined; + + // Make the download request with all parameters + const response = await apiDownloaderDownloadCreate({ + url: videoUrl, + ext: selectedExtension, + video_quality: videoQuality, + audio_quality: audioQuality, + // Advanced options + subtitles: subtitles || undefined, + embed_subtitles: embedSubtitles, + embed_thumbnail: embedThumbnail, + extract_audio: extractAudio, + start_time: startTime || undefined, + end_time: endTime || undefined, + playlist_items: playlistItems || undefined, + cookies: cookies || undefined, + }); + + // The response should be a Blob, trigger download + const blob = new Blob([response as any], { type: 'application/octet-stream' }); + const url = window.URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = `video.${selectedExtension}`; + document.body.appendChild(a); + a.click(); + window.URL.revokeObjectURL(url); + document.body.removeChild(a); + } catch (err: any) { + setError({ error: err.message || 'Failed to download video' }); + } finally { + setIsDownloading(false); + } + } return ( -
+

Video Downloader

- setVideoUrl(e.target.value)} - placeholder="Paste video URL here" - className="w-full p-2 border rounded mb-4" - /> +
+ setVideoUrl(e.target.value)} + placeholder="Paste video URL here (YouTube, TikTok, Vimeo, etc.)" + className="w-full p-2 border rounded" + /> +
- + + + {error && ( +
+ Error: {error.error} +
+ )} - {isLoading &&

Loading video info...

} - - {error &&

Error: {error?.error}

} - {videoInfo && ( -
-

{videoInfo.title}

+
+

{videoInfo.title}

+ {videoInfo.thumbnail && ( - {videoInfo.title} + {videoInfo.title} )} -

Duration: {videoInfo.duration}s

-

Available Video Qualities:

-
    - {videoInfo.video_resolutions?.map((res) => ( -
  • {res}
  • - ))} -
- -

Available Audio Qualities:

-
    - {videoInfo.audio_resolutions?.map((res) => ( -
  • {res}
  • - ))} -
+ {videoInfo.duration && ( +

+ Duration: {Math.floor(videoInfo.duration / 60)}:{String(videoInfo.duration % 60).padStart(2, '0')} +

+ )} + +
+ {/* Video Quality Dropdown */} +
+ + +
+ + {/* Audio Quality Dropdown */} +
+ + +
+ + {/* File Extension Dropdown */} +
+ + +
+
+ + + + {/* Advanced Options Toggle */} +
+ + + {showAdvanced && ( +
+ {/* Subtitles */} +
+ + setSubtitles(e.target.value)} + placeholder="e.g., 'en', 'en,cs', or 'all'" + className="w-full p-2 border rounded" + /> +

+ Language codes (e.g., 'en', 'cs') or 'all' for all available +

+
+ + {/* Checkboxes Row */} +
+ + + + + +
+ + {/* Trim Times */} +
+
+ + setStartTime(e.target.value)} + placeholder="e.g., 00:01:30 or 90" + className="w-full p-2 border rounded" + /> +
+ +
+ + setEndTime(e.target.value)} + placeholder="e.g., 00:05:00 or 300" + className="w-full p-2 border rounded" + /> +
+
+ + {/* Playlist Items */} +
+ + setPlaylistItems(e.target.value)} + placeholder="e.g., '1-5,8,10' or '1,2,3'" + className="w-full p-2 border rounded" + /> +

+ Specify which playlist items to download (e.g., '1-5,8,10') +

+
+ + {/* Cookies for Age-Restricted Content */} +
+ +