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.
This commit is contained in:
233
backend/thirdparty/downloader/views.py
vendored
233
backend/thirdparty/downloader/views.py
vendored
@@ -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")
|
||||
|
||||
# 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")) # 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)
|
||||
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,12 +307,70 @@ 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:
|
||||
with yt_dlp.YoutubeDL(ydl_options) as ydl:
|
||||
@@ -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),
|
||||
|
||||
@@ -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<X, Y, A = X, B = never> =
|
||||
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
|
||||
|
||||
type WritableKeys<T> = {
|
||||
[P in keyof T]-?: IfEquals<
|
||||
{ [Q in P]: T[P] },
|
||||
{ -readonly [Q in P]: T[P] },
|
||||
P
|
||||
>;
|
||||
}[keyof T];
|
||||
|
||||
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
||||
k: infer I,
|
||||
) => void
|
||||
? I
|
||||
: never;
|
||||
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never;
|
||||
|
||||
type Writable<T> = Pick<T, WritableKeys<T>>;
|
||||
type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
|
||||
? {
|
||||
[P in keyof Writable<T>]: T[P] extends object
|
||||
? NonReadonly<NonNullable<T[P]>>
|
||||
: T[P];
|
||||
}
|
||||
: DistributeReadOnlyOverUnions<T>;
|
||||
|
||||
/**
|
||||
* @summary List contact messages (admin)
|
||||
*/
|
||||
export const apiAdvertisementContactMessagesList = (
|
||||
params?: ApiAdvertisementContactMessagesListParams,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<PaginatedContactMeList>({
|
||||
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<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiAdvertisementContactMessagesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ??
|
||||
getApiAdvertisementContactMessagesListQueryKey(params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>
|
||||
> = ({ signal }) => apiAdvertisementContactMessagesList(params, signal);
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiAdvertisementContactMessagesListQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>
|
||||
>;
|
||||
export type ApiAdvertisementContactMessagesListQueryError = unknown;
|
||||
|
||||
export function useApiAdvertisementContactMessagesList<
|
||||
TData = Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params: undefined | ApiAdvertisementContactMessagesListParams,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiAdvertisementContactMessagesList<
|
||||
TData = Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiAdvertisementContactMessagesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiAdvertisementContactMessagesList<
|
||||
TData = Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiAdvertisementContactMessagesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary List contact messages (admin)
|
||||
*/
|
||||
|
||||
export function useApiAdvertisementContactMessagesList<
|
||||
TData = Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiAdvertisementContactMessagesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiAdvertisementContactMessagesListQueryOptions(
|
||||
params,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Create contact message (admin)
|
||||
*/
|
||||
export const apiAdvertisementContactMessagesCreate = (
|
||||
contactMe: NonReadonly<ContactMe>,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<ContactMe>({
|
||||
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<ReturnType<typeof apiAdvertisementContactMessagesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<ContactMe> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<ContactMe> },
|
||||
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<ReturnType<typeof apiAdvertisementContactMessagesCreate>>,
|
||||
{ data: NonReadonly<ContactMe> }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiAdvertisementContactMessagesCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAdvertisementContactMessagesCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesCreate>>
|
||||
>;
|
||||
export type ApiAdvertisementContactMessagesCreateMutationBody =
|
||||
NonReadonly<ContactMe>;
|
||||
export type ApiAdvertisementContactMessagesCreateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Create contact message (admin)
|
||||
*/
|
||||
export const useApiAdvertisementContactMessagesCreate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<ContactMe> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<ContactMe> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiAdvertisementContactMessagesCreateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve contact message (admin)
|
||||
*/
|
||||
export const apiAdvertisementContactMessagesRetrieve = (
|
||||
id: number,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<ContactMe>({
|
||||
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<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ??
|
||||
getApiAdvertisementContactMessagesRetrieveQueryKey(id);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>
|
||||
> = ({ signal }) => apiAdvertisementContactMessagesRetrieve(id, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!id,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiAdvertisementContactMessagesRetrieveQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>
|
||||
>;
|
||||
export type ApiAdvertisementContactMessagesRetrieveQueryError = unknown;
|
||||
|
||||
export function useApiAdvertisementContactMessagesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiAdvertisementContactMessagesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiAdvertisementContactMessagesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve contact message (admin)
|
||||
*/
|
||||
|
||||
export function useApiAdvertisementContactMessagesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiAdvertisementContactMessagesRetrieveQueryOptions(
|
||||
id,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Replace contact message (admin)
|
||||
*/
|
||||
export const apiAdvertisementContactMessagesUpdate = (
|
||||
id: number,
|
||||
contactMe: NonReadonly<ContactMe>,
|
||||
) => {
|
||||
return privateMutator<ContactMe>({
|
||||
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<ReturnType<typeof apiAdvertisementContactMessagesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<ContactMe> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<ContactMe> },
|
||||
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<ReturnType<typeof apiAdvertisementContactMessagesUpdate>>,
|
||||
{ id: number; data: NonReadonly<ContactMe> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiAdvertisementContactMessagesUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAdvertisementContactMessagesUpdateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesUpdate>>
|
||||
>;
|
||||
export type ApiAdvertisementContactMessagesUpdateMutationBody =
|
||||
NonReadonly<ContactMe>;
|
||||
export type ApiAdvertisementContactMessagesUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Replace contact message (admin)
|
||||
*/
|
||||
export const useApiAdvertisementContactMessagesUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<ContactMe> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<ContactMe> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiAdvertisementContactMessagesUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Update contact message (admin)
|
||||
*/
|
||||
export const apiAdvertisementContactMessagesPartialUpdate = (
|
||||
id: number,
|
||||
patchedContactMe: NonReadonly<PatchedContactMe>,
|
||||
) => {
|
||||
return privateMutator<ContactMe>({
|
||||
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<ReturnType<typeof apiAdvertisementContactMessagesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedContactMe> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedContactMe> },
|
||||
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<ReturnType<typeof apiAdvertisementContactMessagesPartialUpdate>>,
|
||||
{ id: number; data: NonReadonly<PatchedContactMe> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiAdvertisementContactMessagesPartialUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAdvertisementContactMessagesPartialUpdateMutationResult =
|
||||
NonNullable<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesPartialUpdate>>
|
||||
>;
|
||||
export type ApiAdvertisementContactMessagesPartialUpdateMutationBody =
|
||||
NonReadonly<PatchedContactMe>;
|
||||
export type ApiAdvertisementContactMessagesPartialUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Update contact message (admin)
|
||||
*/
|
||||
export const useApiAdvertisementContactMessagesPartialUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedContactMe> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedContactMe> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiAdvertisementContactMessagesPartialUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Delete contact message (admin)
|
||||
*/
|
||||
export const apiAdvertisementContactMessagesDestroy = (id: number) => {
|
||||
return privateMutator<void>({
|
||||
url: `/api/advertisement/contact-messages/${id}/`,
|
||||
method: "DELETE",
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiAdvertisementContactMessagesDestroyMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesDestroy>>,
|
||||
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<ReturnType<typeof apiAdvertisementContactMessagesDestroy>>,
|
||||
{ id: number }
|
||||
> = (props) => {
|
||||
const { id } = props ?? {};
|
||||
|
||||
return apiAdvertisementContactMessagesDestroy(id);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAdvertisementContactMessagesDestroyMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesDestroy>>
|
||||
>;
|
||||
|
||||
export type ApiAdvertisementContactMessagesDestroyMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Delete contact message (admin)
|
||||
*/
|
||||
export const useApiAdvertisementContactMessagesDestroy = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMessagesDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiAdvertisementContactMessagesDestroyMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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<X, Y, A = X, B = never> =
|
||||
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
|
||||
|
||||
type WritableKeys<T> = {
|
||||
[P in keyof T]-?: IfEquals<
|
||||
{ [Q in P]: T[P] },
|
||||
{ -readonly [Q in P]: T[P] },
|
||||
P
|
||||
>;
|
||||
}[keyof T];
|
||||
|
||||
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
||||
k: infer I,
|
||||
) => void
|
||||
? I
|
||||
: never;
|
||||
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never;
|
||||
|
||||
type Writable<T> = Pick<T, WritableKeys<T>>;
|
||||
type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
|
||||
? {
|
||||
[P in keyof Writable<T>]: T[P] extends object
|
||||
? NonReadonly<NonNullable<T[P]>>
|
||||
: T[P];
|
||||
}
|
||||
: DistributeReadOnlyOverUnions<T>;
|
||||
|
||||
/**
|
||||
* @summary List categories (public)
|
||||
*/
|
||||
export const apiCommerceCategoriesList = (
|
||||
params?: ApiCommerceCategoriesListParams,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<PaginatedCategoryList>({
|
||||
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<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceCategoriesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiCommerceCategoriesListQueryKey(params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesList>>
|
||||
> = ({ signal }) => apiCommerceCategoriesList(params, signal);
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiCommerceCategoriesListQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesList>>
|
||||
>;
|
||||
export type ApiCommerceCategoriesListQueryError = unknown;
|
||||
|
||||
export function useApiCommerceCategoriesList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params: undefined | ApiCommerceCategoriesListParams,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceCategoriesList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceCategoriesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceCategoriesList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceCategoriesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary List categories (public)
|
||||
*/
|
||||
|
||||
export function useApiCommerceCategoriesList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceCategoriesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiCommerceCategoriesListQueryOptions(
|
||||
params,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Create category (auth required)
|
||||
*/
|
||||
export const apiCommerceCategoriesCreate = (
|
||||
category: NonReadonly<Category>,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<Category>({
|
||||
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<ReturnType<typeof apiCommerceCategoriesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<Category> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<Category> },
|
||||
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<ReturnType<typeof apiCommerceCategoriesCreate>>,
|
||||
{ data: NonReadonly<Category> }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiCommerceCategoriesCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceCategoriesCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesCreate>>
|
||||
>;
|
||||
export type ApiCommerceCategoriesCreateMutationBody = NonReadonly<Category>;
|
||||
export type ApiCommerceCategoriesCreateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Create category (auth required)
|
||||
*/
|
||||
export const useApiCommerceCategoriesCreate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<Category> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<Category> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceCategoriesCreateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve category (public)
|
||||
*/
|
||||
export const apiCommerceCategoriesRetrieve = (
|
||||
id: number,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<Category>({
|
||||
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<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiCommerceCategoriesRetrieveQueryKey(id);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>
|
||||
> = ({ signal }) => apiCommerceCategoriesRetrieve(id, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!id,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiCommerceCategoriesRetrieveQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>
|
||||
>;
|
||||
export type ApiCommerceCategoriesRetrieveQueryError = unknown;
|
||||
|
||||
export function useApiCommerceCategoriesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceCategoriesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceCategoriesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve category (public)
|
||||
*/
|
||||
|
||||
export function useApiCommerceCategoriesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiCommerceCategoriesRetrieveQueryOptions(
|
||||
id,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Replace category (auth required)
|
||||
*/
|
||||
export const apiCommerceCategoriesUpdate = (
|
||||
id: number,
|
||||
category: NonReadonly<Category>,
|
||||
) => {
|
||||
return privateMutator<Category>({
|
||||
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<ReturnType<typeof apiCommerceCategoriesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<Category> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<Category> },
|
||||
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<ReturnType<typeof apiCommerceCategoriesUpdate>>,
|
||||
{ id: number; data: NonReadonly<Category> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiCommerceCategoriesUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceCategoriesUpdateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesUpdate>>
|
||||
>;
|
||||
export type ApiCommerceCategoriesUpdateMutationBody = NonReadonly<Category>;
|
||||
export type ApiCommerceCategoriesUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Replace category (auth required)
|
||||
*/
|
||||
export const useApiCommerceCategoriesUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<Category> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<Category> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceCategoriesUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Update category (auth required)
|
||||
*/
|
||||
export const apiCommerceCategoriesPartialUpdate = (
|
||||
id: number,
|
||||
patchedCategory: NonReadonly<PatchedCategory>,
|
||||
) => {
|
||||
return privateMutator<Category>({
|
||||
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<ReturnType<typeof apiCommerceCategoriesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedCategory> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedCategory> },
|
||||
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<ReturnType<typeof apiCommerceCategoriesPartialUpdate>>,
|
||||
{ id: number; data: NonReadonly<PatchedCategory> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiCommerceCategoriesPartialUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceCategoriesPartialUpdateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesPartialUpdate>>
|
||||
>;
|
||||
export type ApiCommerceCategoriesPartialUpdateMutationBody =
|
||||
NonReadonly<PatchedCategory>;
|
||||
export type ApiCommerceCategoriesPartialUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Update category (auth required)
|
||||
*/
|
||||
export const useApiCommerceCategoriesPartialUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedCategory> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedCategory> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceCategoriesPartialUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Delete category (auth required)
|
||||
*/
|
||||
export const apiCommerceCategoriesDestroy = (id: number) => {
|
||||
return privateMutator<void>({
|
||||
url: `/api/commerce/categories/${id}/`,
|
||||
method: "DELETE",
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiCommerceCategoriesDestroyMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesDestroy>>,
|
||||
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<ReturnType<typeof apiCommerceCategoriesDestroy>>,
|
||||
{ id: number }
|
||||
> = (props) => {
|
||||
const { id } = props ?? {};
|
||||
|
||||
return apiCommerceCategoriesDestroy(id);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceCategoriesDestroyMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesDestroy>>
|
||||
>;
|
||||
|
||||
export type ApiCommerceCategoriesDestroyMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Delete category (auth required)
|
||||
*/
|
||||
export const useApiCommerceCategoriesDestroy = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceCategoriesDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceCategoriesDestroyMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
2073
frontend/src/api/generated/private/commerce/commerce.ts
Normal file
2073
frontend/src/api/generated/private/commerce/commerce.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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<X, Y, A = X, B = never> =
|
||||
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
|
||||
|
||||
type WritableKeys<T> = {
|
||||
[P in keyof T]-?: IfEquals<
|
||||
{ [Q in P]: T[P] },
|
||||
{ -readonly [Q in P]: T[P] },
|
||||
P
|
||||
>;
|
||||
}[keyof T];
|
||||
|
||||
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
||||
k: infer I,
|
||||
) => void
|
||||
? I
|
||||
: never;
|
||||
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never;
|
||||
|
||||
type Writable<T> = Pick<T, WritableKeys<T>>;
|
||||
type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
|
||||
? {
|
||||
[P in keyof Writable<T>]: T[P] extends object
|
||||
? NonReadonly<NonNullable<T[P]>>
|
||||
: T[P];
|
||||
}
|
||||
: DistributeReadOnlyOverUnions<T>;
|
||||
|
||||
/**
|
||||
* @summary List site configuration (admin)
|
||||
*/
|
||||
export const apiConfigurationAdminShopConfigurationList = (
|
||||
params?: ApiConfigurationAdminShopConfigurationListParams,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<PaginatedSiteConfigurationAdminList>({
|
||||
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<typeof apiConfigurationAdminShopConfigurationList>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiConfigurationAdminShopConfigurationListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ??
|
||||
getApiConfigurationAdminShopConfigurationListQueryKey(params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>
|
||||
> = ({ signal }) =>
|
||||
apiConfigurationAdminShopConfigurationList(params, signal);
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiConfigurationAdminShopConfigurationListQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>
|
||||
>;
|
||||
export type ApiConfigurationAdminShopConfigurationListQueryError = unknown;
|
||||
|
||||
export function useApiConfigurationAdminShopConfigurationList<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationList>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params: undefined | ApiConfigurationAdminShopConfigurationListParams,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationList>
|
||||
>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiConfigurationAdminShopConfigurationList<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationList>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiConfigurationAdminShopConfigurationListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationList>
|
||||
>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiConfigurationAdminShopConfigurationList<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationList>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiConfigurationAdminShopConfigurationListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary List site configuration (admin)
|
||||
*/
|
||||
|
||||
export function useApiConfigurationAdminShopConfigurationList<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationList>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiConfigurationAdminShopConfigurationListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions =
|
||||
getApiConfigurationAdminShopConfigurationListQueryOptions(params, options);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Create site configuration (admin)
|
||||
*/
|
||||
export const apiConfigurationAdminShopConfigurationCreate = (
|
||||
siteConfigurationAdmin: NonReadonly<SiteConfigurationAdmin>,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<SiteConfigurationAdmin>({
|
||||
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<ReturnType<typeof apiConfigurationAdminShopConfigurationCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<SiteConfigurationAdmin> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<SiteConfigurationAdmin> },
|
||||
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<ReturnType<typeof apiConfigurationAdminShopConfigurationCreate>>,
|
||||
{ data: NonReadonly<SiteConfigurationAdmin> }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiConfigurationAdminShopConfigurationCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiConfigurationAdminShopConfigurationCreateMutationResult =
|
||||
NonNullable<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationCreate>>
|
||||
>;
|
||||
export type ApiConfigurationAdminShopConfigurationCreateMutationBody =
|
||||
NonReadonly<SiteConfigurationAdmin>;
|
||||
export type ApiConfigurationAdminShopConfigurationCreateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Create site configuration (admin)
|
||||
*/
|
||||
export const useApiConfigurationAdminShopConfigurationCreate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<SiteConfigurationAdmin> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<SiteConfigurationAdmin> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiConfigurationAdminShopConfigurationCreateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve site configuration (admin)
|
||||
*/
|
||||
export const apiConfigurationAdminShopConfigurationRetrieve = (
|
||||
id: number,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<SiteConfigurationAdmin>({
|
||||
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<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ??
|
||||
getApiConfigurationAdminShopConfigurationRetrieveQueryKey(id);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>>
|
||||
> = ({ signal }) =>
|
||||
apiConfigurationAdminShopConfigurationRetrieve(id, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!id,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiConfigurationAdminShopConfigurationRetrieveQueryResult =
|
||||
NonNullable<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>>
|
||||
>;
|
||||
export type ApiConfigurationAdminShopConfigurationRetrieveQueryError = unknown;
|
||||
|
||||
export function useApiConfigurationAdminShopConfigurationRetrieve<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiConfigurationAdminShopConfigurationRetrieve<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiConfigurationAdminShopConfigurationRetrieve<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve site configuration (admin)
|
||||
*/
|
||||
|
||||
export function useApiConfigurationAdminShopConfigurationRetrieve<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions =
|
||||
getApiConfigurationAdminShopConfigurationRetrieveQueryOptions(id, options);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Replace site configuration (admin)
|
||||
*/
|
||||
export const apiConfigurationAdminShopConfigurationUpdate = (
|
||||
id: number,
|
||||
siteConfigurationAdmin: NonReadonly<SiteConfigurationAdmin>,
|
||||
) => {
|
||||
return privateMutator<SiteConfigurationAdmin>({
|
||||
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<ReturnType<typeof apiConfigurationAdminShopConfigurationUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<SiteConfigurationAdmin> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<SiteConfigurationAdmin> },
|
||||
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<ReturnType<typeof apiConfigurationAdminShopConfigurationUpdate>>,
|
||||
{ id: number; data: NonReadonly<SiteConfigurationAdmin> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiConfigurationAdminShopConfigurationUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiConfigurationAdminShopConfigurationUpdateMutationResult =
|
||||
NonNullable<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationUpdate>>
|
||||
>;
|
||||
export type ApiConfigurationAdminShopConfigurationUpdateMutationBody =
|
||||
NonReadonly<SiteConfigurationAdmin>;
|
||||
export type ApiConfigurationAdminShopConfigurationUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Replace site configuration (admin)
|
||||
*/
|
||||
export const useApiConfigurationAdminShopConfigurationUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<SiteConfigurationAdmin> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<SiteConfigurationAdmin> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiConfigurationAdminShopConfigurationUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Update site configuration (admin)
|
||||
*/
|
||||
export const apiConfigurationAdminShopConfigurationPartialUpdate = (
|
||||
id: number,
|
||||
patchedSiteConfigurationAdmin: NonReadonly<PatchedSiteConfigurationAdmin>,
|
||||
) => {
|
||||
return privateMutator<SiteConfigurationAdmin>({
|
||||
url: `/api/configuration/admin/shop-configuration/${id}/`,
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
data: patchedSiteConfigurationAdmin,
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiConfigurationAdminShopConfigurationPartialUpdateMutationOptions =
|
||||
<TError = unknown, TContext = unknown>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationPartialUpdate>
|
||||
>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedSiteConfigurationAdmin> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationPartialUpdate>
|
||||
>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedSiteConfigurationAdmin> },
|
||||
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<typeof apiConfigurationAdminShopConfigurationPartialUpdate>
|
||||
>,
|
||||
{ id: number; data: NonReadonly<PatchedSiteConfigurationAdmin> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiConfigurationAdminShopConfigurationPartialUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiConfigurationAdminShopConfigurationPartialUpdateMutationResult =
|
||||
NonNullable<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationPartialUpdate>
|
||||
>
|
||||
>;
|
||||
export type ApiConfigurationAdminShopConfigurationPartialUpdateMutationBody =
|
||||
NonReadonly<PatchedSiteConfigurationAdmin>;
|
||||
export type ApiConfigurationAdminShopConfigurationPartialUpdateMutationError =
|
||||
unknown;
|
||||
|
||||
/**
|
||||
* @summary Update site configuration (admin)
|
||||
*/
|
||||
export const useApiConfigurationAdminShopConfigurationPartialUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationPartialUpdate>
|
||||
>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedSiteConfigurationAdmin> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationAdminShopConfigurationPartialUpdate>
|
||||
>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedSiteConfigurationAdmin> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiConfigurationAdminShopConfigurationPartialUpdateMutationOptions(
|
||||
options,
|
||||
);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Delete site configuration (admin)
|
||||
*/
|
||||
export const apiConfigurationAdminShopConfigurationDestroy = (id: number) => {
|
||||
return privateMutator<void>({
|
||||
url: `/api/configuration/admin/shop-configuration/${id}/`,
|
||||
method: "DELETE",
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiConfigurationAdminShopConfigurationDestroyMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationDestroy>>,
|
||||
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<ReturnType<typeof apiConfigurationAdminShopConfigurationDestroy>>,
|
||||
{ id: number }
|
||||
> = (props) => {
|
||||
const { id } = props ?? {};
|
||||
|
||||
return apiConfigurationAdminShopConfigurationDestroy(id);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiConfigurationAdminShopConfigurationDestroyMutationResult =
|
||||
NonNullable<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationDestroy>>
|
||||
>;
|
||||
|
||||
export type ApiConfigurationAdminShopConfigurationDestroyMutationError =
|
||||
unknown;
|
||||
|
||||
/**
|
||||
* @summary Delete site configuration (admin)
|
||||
*/
|
||||
export const useApiConfigurationAdminShopConfigurationDestroy = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiConfigurationAdminShopConfigurationDestroyMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
@@ -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<X, Y, A = X, B = never> =
|
||||
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
|
||||
|
||||
type WritableKeys<T> = {
|
||||
[P in keyof T]-?: IfEquals<
|
||||
{ [Q in P]: T[P] },
|
||||
{ -readonly [Q in P]: T[P] },
|
||||
P
|
||||
>;
|
||||
}[keyof T];
|
||||
|
||||
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
||||
k: infer I,
|
||||
) => void
|
||||
? I
|
||||
: never;
|
||||
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never;
|
||||
|
||||
type Writable<T> = Pick<T, WritableKeys<T>>;
|
||||
type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
|
||||
? {
|
||||
[P in keyof Writable<T>]: T[P] extends object
|
||||
? NonReadonly<NonNullable<T[P]>>
|
||||
: T[P];
|
||||
}
|
||||
: DistributeReadOnlyOverUnions<T>;
|
||||
|
||||
/**
|
||||
* @summary List discount codes (public)
|
||||
*/
|
||||
export const apiCommerceDiscountCodesList = (
|
||||
params?: ApiCommerceDiscountCodesListParams,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<PaginatedDiscountCodeList>({
|
||||
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<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceDiscountCodesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiCommerceDiscountCodesListQueryKey(params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>
|
||||
> = ({ signal }) => apiCommerceDiscountCodesList(params, signal);
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiCommerceDiscountCodesListQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>
|
||||
>;
|
||||
export type ApiCommerceDiscountCodesListQueryError = unknown;
|
||||
|
||||
export function useApiCommerceDiscountCodesList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params: undefined | ApiCommerceDiscountCodesListParams,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceDiscountCodesList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceDiscountCodesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceDiscountCodesList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceDiscountCodesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary List discount codes (public)
|
||||
*/
|
||||
|
||||
export function useApiCommerceDiscountCodesList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceDiscountCodesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiCommerceDiscountCodesListQueryOptions(
|
||||
params,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Create discount code (auth required)
|
||||
*/
|
||||
export const apiCommerceDiscountCodesCreate = (
|
||||
discountCode: NonReadonly<DiscountCode>,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<DiscountCode>({
|
||||
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<ReturnType<typeof apiCommerceDiscountCodesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<DiscountCode> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<DiscountCode> },
|
||||
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<ReturnType<typeof apiCommerceDiscountCodesCreate>>,
|
||||
{ data: NonReadonly<DiscountCode> }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiCommerceDiscountCodesCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceDiscountCodesCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesCreate>>
|
||||
>;
|
||||
export type ApiCommerceDiscountCodesCreateMutationBody =
|
||||
NonReadonly<DiscountCode>;
|
||||
export type ApiCommerceDiscountCodesCreateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Create discount code (auth required)
|
||||
*/
|
||||
export const useApiCommerceDiscountCodesCreate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<DiscountCode> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<DiscountCode> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceDiscountCodesCreateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve discount code (public)
|
||||
*/
|
||||
export const apiCommerceDiscountCodesRetrieve = (
|
||||
id: number,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<DiscountCode>({
|
||||
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<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiCommerceDiscountCodesRetrieveQueryKey(id);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>
|
||||
> = ({ signal }) => apiCommerceDiscountCodesRetrieve(id, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!id,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiCommerceDiscountCodesRetrieveQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>
|
||||
>;
|
||||
export type ApiCommerceDiscountCodesRetrieveQueryError = unknown;
|
||||
|
||||
export function useApiCommerceDiscountCodesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceDiscountCodesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceDiscountCodesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve discount code (public)
|
||||
*/
|
||||
|
||||
export function useApiCommerceDiscountCodesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiCommerceDiscountCodesRetrieveQueryOptions(
|
||||
id,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Replace discount code (auth required)
|
||||
*/
|
||||
export const apiCommerceDiscountCodesUpdate = (
|
||||
id: number,
|
||||
discountCode: NonReadonly<DiscountCode>,
|
||||
) => {
|
||||
return privateMutator<DiscountCode>({
|
||||
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<ReturnType<typeof apiCommerceDiscountCodesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<DiscountCode> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<DiscountCode> },
|
||||
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<ReturnType<typeof apiCommerceDiscountCodesUpdate>>,
|
||||
{ id: number; data: NonReadonly<DiscountCode> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiCommerceDiscountCodesUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceDiscountCodesUpdateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesUpdate>>
|
||||
>;
|
||||
export type ApiCommerceDiscountCodesUpdateMutationBody =
|
||||
NonReadonly<DiscountCode>;
|
||||
export type ApiCommerceDiscountCodesUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Replace discount code (auth required)
|
||||
*/
|
||||
export const useApiCommerceDiscountCodesUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<DiscountCode> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<DiscountCode> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceDiscountCodesUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Update discount code (auth required)
|
||||
*/
|
||||
export const apiCommerceDiscountCodesPartialUpdate = (
|
||||
id: number,
|
||||
patchedDiscountCode: NonReadonly<PatchedDiscountCode>,
|
||||
) => {
|
||||
return privateMutator<DiscountCode>({
|
||||
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<ReturnType<typeof apiCommerceDiscountCodesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedDiscountCode> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedDiscountCode> },
|
||||
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<ReturnType<typeof apiCommerceDiscountCodesPartialUpdate>>,
|
||||
{ id: number; data: NonReadonly<PatchedDiscountCode> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiCommerceDiscountCodesPartialUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceDiscountCodesPartialUpdateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesPartialUpdate>>
|
||||
>;
|
||||
export type ApiCommerceDiscountCodesPartialUpdateMutationBody =
|
||||
NonReadonly<PatchedDiscountCode>;
|
||||
export type ApiCommerceDiscountCodesPartialUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Update discount code (auth required)
|
||||
*/
|
||||
export const useApiCommerceDiscountCodesPartialUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedDiscountCode> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedDiscountCode> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceDiscountCodesPartialUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Delete discount code (auth required)
|
||||
*/
|
||||
export const apiCommerceDiscountCodesDestroy = (id: number) => {
|
||||
return privateMutator<void>({
|
||||
url: `/api/commerce/discount-codes/${id}/`,
|
||||
method: "DELETE",
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiCommerceDiscountCodesDestroyMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesDestroy>>,
|
||||
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<ReturnType<typeof apiCommerceDiscountCodesDestroy>>,
|
||||
{ id: number }
|
||||
> = (props) => {
|
||||
const { id } = props ?? {};
|
||||
|
||||
return apiCommerceDiscountCodesDestroy(id);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceDiscountCodesDestroyMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesDestroy>>
|
||||
>;
|
||||
|
||||
export type ApiCommerceDiscountCodesDestroyMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Delete discount code (auth required)
|
||||
*/
|
||||
export const useApiCommerceDiscountCodesDestroy = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceDiscountCodesDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceDiscountCodesDestroyMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
@@ -6,5 +6,4 @@
|
||||
|
||||
export interface DownloadErrorResponse {
|
||||
error: string;
|
||||
allowed?: string[];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
*/
|
||||
|
||||
export interface ErrorResponse {
|
||||
/** Error message describing what went wrong */
|
||||
error: string;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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";
|
||||
|
||||
@@ -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[];
|
||||
}
|
||||
|
||||
@@ -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<OrderRead>({
|
||||
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<ReturnType<typeof apiCommerceOrdersCreate>>,
|
||||
TError,
|
||||
{ data: OrderCreate },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersCreate>>,
|
||||
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<ReturnType<typeof apiCommerceOrdersCreate>>,
|
||||
{ data: OrderCreate }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiCommerceOrdersCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceOrdersCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersCreate>>
|
||||
>;
|
||||
export type ApiCommerceOrdersCreateMutationBody = OrderCreate;
|
||||
export type ApiCommerceOrdersCreateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Create Order (public)
|
||||
*/
|
||||
export const useApiCommerceOrdersCreate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersCreate>>,
|
||||
TError,
|
||||
{ data: OrderCreate },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersCreate>>,
|
||||
TError,
|
||||
{ data: OrderCreate },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getApiCommerceOrdersCreateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
@@ -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<PaginatedOrderReadList>({
|
||||
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<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceOrdersListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiCommerceOrdersListQueryKey(params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersList>>
|
||||
> = ({ signal }) => apiCommerceOrdersList(params, signal);
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiCommerceOrdersListQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersList>>
|
||||
>;
|
||||
export type ApiCommerceOrdersListQueryError = unknown;
|
||||
|
||||
export function useApiCommerceOrdersList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params: undefined | ApiCommerceOrdersListParams,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceOrdersList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceOrdersListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceOrdersList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceOrdersListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary List Orders (public)
|
||||
*/
|
||||
|
||||
export function useApiCommerceOrdersList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceOrdersListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiCommerceOrdersListQueryOptions(params, options);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Retrieve Order (public)
|
||||
*/
|
||||
export const apiCommerceOrdersRetrieve = (id: number, signal?: AbortSignal) => {
|
||||
return privateMutator<OrderRead>({
|
||||
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<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiCommerceOrdersRetrieveQueryKey(id);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>
|
||||
> = ({ signal }) => apiCommerceOrdersRetrieve(id, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!id,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiCommerceOrdersRetrieveQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>
|
||||
>;
|
||||
export type ApiCommerceOrdersRetrieveQueryError = unknown;
|
||||
|
||||
export function useApiCommerceOrdersRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceOrdersRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceOrdersRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve Order (public)
|
||||
*/
|
||||
|
||||
export function useApiCommerceOrdersRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiCommerceOrdersRetrieveQueryOptions(id, options);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
@@ -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<PaginatedZasilkovnaShipmentList>({
|
||||
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<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiZasilkovnaShipmentsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiZasilkovnaShipmentsListQueryKey(params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>
|
||||
> = ({ signal }) => apiZasilkovnaShipmentsList(params, signal);
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiZasilkovnaShipmentsListQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>
|
||||
>;
|
||||
export type ApiZasilkovnaShipmentsListQueryError = unknown;
|
||||
|
||||
export function useApiZasilkovnaShipmentsList<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params: undefined | ApiZasilkovnaShipmentsListParams,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiZasilkovnaShipmentsList<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiZasilkovnaShipmentsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiZasilkovnaShipmentsList<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiZasilkovnaShipmentsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Hromadný shipment
|
||||
*/
|
||||
|
||||
export function useApiZasilkovnaShipmentsList<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiZasilkovnaShipmentsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiZasilkovnaShipmentsListQueryOptions(
|
||||
params,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
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<ZasilkovnaShipment>({
|
||||
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<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiZasilkovnaShipmentsRetrieveQueryKey(id);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>
|
||||
> = ({ signal }) => apiZasilkovnaShipmentsRetrieve(id, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!id,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiZasilkovnaShipmentsRetrieveQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>
|
||||
>;
|
||||
export type ApiZasilkovnaShipmentsRetrieveQueryError = unknown;
|
||||
|
||||
export function useApiZasilkovnaShipmentsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiZasilkovnaShipmentsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiZasilkovnaShipmentsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Detail hromadné zásilky
|
||||
*/
|
||||
|
||||
export function useApiZasilkovnaShipmentsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiZasilkovnaShipmentsRetrieveQueryOptions(
|
||||
id,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
@@ -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<X, Y, A = X, B = never> =
|
||||
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
|
||||
|
||||
type WritableKeys<T> = {
|
||||
[P in keyof T]-?: IfEquals<
|
||||
{ [Q in P]: T[P] },
|
||||
{ -readonly [Q in P]: T[P] },
|
||||
P
|
||||
>;
|
||||
}[keyof T];
|
||||
|
||||
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
||||
k: infer I,
|
||||
) => void
|
||||
? I
|
||||
: never;
|
||||
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never;
|
||||
|
||||
type Writable<T> = Pick<T, WritableKeys<T>>;
|
||||
type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
|
||||
? {
|
||||
[P in keyof Writable<T>]: T[P] extends object
|
||||
? NonReadonly<NonNullable<T[P]>>
|
||||
: T[P];
|
||||
}
|
||||
: DistributeReadOnlyOverUnions<T>;
|
||||
|
||||
/**
|
||||
* @summary List product images (public)
|
||||
*/
|
||||
export const apiCommerceProductImagesList = (
|
||||
params?: ApiCommerceProductImagesListParams,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<PaginatedProductImageList>({
|
||||
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<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceProductImagesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiCommerceProductImagesListQueryKey(params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesList>>
|
||||
> = ({ signal }) => apiCommerceProductImagesList(params, signal);
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiCommerceProductImagesListQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesList>>
|
||||
>;
|
||||
export type ApiCommerceProductImagesListQueryError = unknown;
|
||||
|
||||
export function useApiCommerceProductImagesList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params: undefined | ApiCommerceProductImagesListParams,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceProductImagesList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceProductImagesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceProductImagesList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceProductImagesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary List product images (public)
|
||||
*/
|
||||
|
||||
export function useApiCommerceProductImagesList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceProductImagesListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiCommerceProductImagesListQueryOptions(
|
||||
params,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Create product image (auth required)
|
||||
*/
|
||||
export const apiCommerceProductImagesCreate = (
|
||||
productImage: NonReadonly<ProductImage>,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<ProductImage>({
|
||||
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<ReturnType<typeof apiCommerceProductImagesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<ProductImage> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<ProductImage> },
|
||||
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<ReturnType<typeof apiCommerceProductImagesCreate>>,
|
||||
{ data: NonReadonly<ProductImage> }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiCommerceProductImagesCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceProductImagesCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesCreate>>
|
||||
>;
|
||||
export type ApiCommerceProductImagesCreateMutationBody =
|
||||
NonReadonly<ProductImage>;
|
||||
export type ApiCommerceProductImagesCreateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Create product image (auth required)
|
||||
*/
|
||||
export const useApiCommerceProductImagesCreate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<ProductImage> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<ProductImage> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceProductImagesCreateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve product image (public)
|
||||
*/
|
||||
export const apiCommerceProductImagesRetrieve = (
|
||||
id: number,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<ProductImage>({
|
||||
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<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiCommerceProductImagesRetrieveQueryKey(id);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>
|
||||
> = ({ signal }) => apiCommerceProductImagesRetrieve(id, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!id,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiCommerceProductImagesRetrieveQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>
|
||||
>;
|
||||
export type ApiCommerceProductImagesRetrieveQueryError = unknown;
|
||||
|
||||
export function useApiCommerceProductImagesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceProductImagesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceProductImagesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve product image (public)
|
||||
*/
|
||||
|
||||
export function useApiCommerceProductImagesRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiCommerceProductImagesRetrieveQueryOptions(
|
||||
id,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Replace product image (auth required)
|
||||
*/
|
||||
export const apiCommerceProductImagesUpdate = (
|
||||
id: number,
|
||||
productImage: NonReadonly<ProductImage>,
|
||||
) => {
|
||||
return privateMutator<ProductImage>({
|
||||
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<ReturnType<typeof apiCommerceProductImagesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<ProductImage> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<ProductImage> },
|
||||
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<ReturnType<typeof apiCommerceProductImagesUpdate>>,
|
||||
{ id: number; data: NonReadonly<ProductImage> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiCommerceProductImagesUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceProductImagesUpdateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesUpdate>>
|
||||
>;
|
||||
export type ApiCommerceProductImagesUpdateMutationBody =
|
||||
NonReadonly<ProductImage>;
|
||||
export type ApiCommerceProductImagesUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Replace product image (auth required)
|
||||
*/
|
||||
export const useApiCommerceProductImagesUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<ProductImage> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<ProductImage> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceProductImagesUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Update product image (auth required)
|
||||
*/
|
||||
export const apiCommerceProductImagesPartialUpdate = (
|
||||
id: number,
|
||||
patchedProductImage: NonReadonly<PatchedProductImage>,
|
||||
) => {
|
||||
return privateMutator<ProductImage>({
|
||||
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<ReturnType<typeof apiCommerceProductImagesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedProductImage> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedProductImage> },
|
||||
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<ReturnType<typeof apiCommerceProductImagesPartialUpdate>>,
|
||||
{ id: number; data: NonReadonly<PatchedProductImage> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiCommerceProductImagesPartialUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceProductImagesPartialUpdateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesPartialUpdate>>
|
||||
>;
|
||||
export type ApiCommerceProductImagesPartialUpdateMutationBody =
|
||||
NonReadonly<PatchedProductImage>;
|
||||
export type ApiCommerceProductImagesPartialUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Update product image (auth required)
|
||||
*/
|
||||
export const useApiCommerceProductImagesPartialUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedProductImage> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedProductImage> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceProductImagesPartialUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Delete product image (auth required)
|
||||
*/
|
||||
export const apiCommerceProductImagesDestroy = (id: number) => {
|
||||
return privateMutator<void>({
|
||||
url: `/api/commerce/product-images/${id}/`,
|
||||
method: "DELETE",
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiCommerceProductImagesDestroyMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesDestroy>>,
|
||||
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<ReturnType<typeof apiCommerceProductImagesDestroy>>,
|
||||
{ id: number }
|
||||
> = (props) => {
|
||||
const { id } = props ?? {};
|
||||
|
||||
return apiCommerceProductImagesDestroy(id);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceProductImagesDestroyMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesDestroy>>
|
||||
>;
|
||||
|
||||
export type ApiCommerceProductImagesDestroyMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Delete product image (auth required)
|
||||
*/
|
||||
export const useApiCommerceProductImagesDestroy = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceProductImagesDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceProductImagesDestroyMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
@@ -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<X, Y, A = X, B = never> =
|
||||
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
|
||||
|
||||
type WritableKeys<T> = {
|
||||
[P in keyof T]-?: IfEquals<
|
||||
{ [Q in P]: T[P] },
|
||||
{ -readonly [Q in P]: T[P] },
|
||||
P
|
||||
>;
|
||||
}[keyof T];
|
||||
|
||||
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
||||
k: infer I,
|
||||
) => void
|
||||
? I
|
||||
: never;
|
||||
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never;
|
||||
|
||||
type Writable<T> = Pick<T, WritableKeys<T>>;
|
||||
type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
|
||||
? {
|
||||
[P in keyof Writable<T>]: T[P] extends object
|
||||
? NonReadonly<NonNullable<T[P]>>
|
||||
: T[P];
|
||||
}
|
||||
: DistributeReadOnlyOverUnions<T>;
|
||||
|
||||
/**
|
||||
* @summary List products (public)
|
||||
*/
|
||||
export const apiCommerceProductsList = (
|
||||
params?: ApiCommerceProductsListParams,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<PaginatedProductList>({
|
||||
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<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceProductsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiCommerceProductsListQueryKey(params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsList>>
|
||||
> = ({ signal }) => apiCommerceProductsList(params, signal);
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiCommerceProductsListQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsList>>
|
||||
>;
|
||||
export type ApiCommerceProductsListQueryError = unknown;
|
||||
|
||||
export function useApiCommerceProductsList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params: undefined | ApiCommerceProductsListParams,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceProductsList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceProductsList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceProductsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceProductsList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceProductsList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceProductsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary List products (public)
|
||||
*/
|
||||
|
||||
export function useApiCommerceProductsList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceProductsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiCommerceProductsListQueryOptions(params, options);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Create product (auth required)
|
||||
*/
|
||||
export const apiCommerceProductsCreate = (
|
||||
product: NonReadonly<Product>,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<Product>({
|
||||
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<ReturnType<typeof apiCommerceProductsCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<Product> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<Product> },
|
||||
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<ReturnType<typeof apiCommerceProductsCreate>>,
|
||||
{ data: NonReadonly<Product> }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiCommerceProductsCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceProductsCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsCreate>>
|
||||
>;
|
||||
export type ApiCommerceProductsCreateMutationBody = NonReadonly<Product>;
|
||||
export type ApiCommerceProductsCreateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Create product (auth required)
|
||||
*/
|
||||
export const useApiCommerceProductsCreate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<Product> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<Product> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getApiCommerceProductsCreateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve product (public)
|
||||
*/
|
||||
export const apiCommerceProductsRetrieve = (
|
||||
id: number,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<Product>({
|
||||
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<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiCommerceProductsRetrieveQueryKey(id);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>
|
||||
> = ({ signal }) => apiCommerceProductsRetrieve(id, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!id,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiCommerceProductsRetrieveQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>
|
||||
>;
|
||||
export type ApiCommerceProductsRetrieveQueryError = unknown;
|
||||
|
||||
export function useApiCommerceProductsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceProductsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceProductsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve product (public)
|
||||
*/
|
||||
|
||||
export function useApiCommerceProductsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiCommerceProductsRetrieveQueryOptions(id, options);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Replace product (auth required)
|
||||
*/
|
||||
export const apiCommerceProductsUpdate = (
|
||||
id: number,
|
||||
product: NonReadonly<Product>,
|
||||
) => {
|
||||
return privateMutator<Product>({
|
||||
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<ReturnType<typeof apiCommerceProductsUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<Product> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<Product> },
|
||||
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<ReturnType<typeof apiCommerceProductsUpdate>>,
|
||||
{ id: number; data: NonReadonly<Product> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiCommerceProductsUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceProductsUpdateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsUpdate>>
|
||||
>;
|
||||
export type ApiCommerceProductsUpdateMutationBody = NonReadonly<Product>;
|
||||
export type ApiCommerceProductsUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Replace product (auth required)
|
||||
*/
|
||||
export const useApiCommerceProductsUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<Product> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<Product> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getApiCommerceProductsUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Update product (auth required)
|
||||
*/
|
||||
export const apiCommerceProductsPartialUpdate = (
|
||||
id: number,
|
||||
patchedProduct: NonReadonly<PatchedProduct>,
|
||||
) => {
|
||||
return privateMutator<Product>({
|
||||
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<ReturnType<typeof apiCommerceProductsPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedProduct> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedProduct> },
|
||||
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<ReturnType<typeof apiCommerceProductsPartialUpdate>>,
|
||||
{ id: number; data: NonReadonly<PatchedProduct> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiCommerceProductsPartialUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceProductsPartialUpdateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsPartialUpdate>>
|
||||
>;
|
||||
export type ApiCommerceProductsPartialUpdateMutationBody =
|
||||
NonReadonly<PatchedProduct>;
|
||||
export type ApiCommerceProductsPartialUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Update product (auth required)
|
||||
*/
|
||||
export const useApiCommerceProductsPartialUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedProduct> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedProduct> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceProductsPartialUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Delete product (auth required)
|
||||
*/
|
||||
export const apiCommerceProductsDestroy = (id: number) => {
|
||||
return privateMutator<void>({
|
||||
url: `/api/commerce/products/${id}/`,
|
||||
method: "DELETE",
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiCommerceProductsDestroyMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsDestroy>>,
|
||||
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<ReturnType<typeof apiCommerceProductsDestroy>>,
|
||||
{ id: number }
|
||||
> = (props) => {
|
||||
const { id } = props ?? {};
|
||||
|
||||
return apiCommerceProductsDestroy(id);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceProductsDestroyMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsDestroy>>
|
||||
>;
|
||||
|
||||
export type ApiCommerceProductsDestroyMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Delete product (auth required)
|
||||
*/
|
||||
export const useApiCommerceProductsDestroy = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceProductsDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getApiCommerceProductsDestroyMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
@@ -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<X, Y, A = X, B = never> =
|
||||
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
|
||||
|
||||
type WritableKeys<T> = {
|
||||
[P in keyof T]-?: IfEquals<
|
||||
{ [Q in P]: T[P] },
|
||||
{ -readonly [Q in P]: T[P] },
|
||||
P
|
||||
>;
|
||||
}[keyof T];
|
||||
|
||||
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
||||
k: infer I,
|
||||
) => void
|
||||
? I
|
||||
: never;
|
||||
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never;
|
||||
|
||||
type Writable<T> = Pick<T, WritableKeys<T>>;
|
||||
type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
|
||||
? {
|
||||
[P in keyof Writable<T>]: T[P] extends object
|
||||
? NonReadonly<NonNullable<T[P]>>
|
||||
: T[P];
|
||||
}
|
||||
: DistributeReadOnlyOverUnions<T>;
|
||||
|
||||
/**
|
||||
* @summary List refunds (admin)
|
||||
*/
|
||||
export const apiCommerceRefundsList = (
|
||||
params?: ApiCommerceRefundsListParams,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<PaginatedRefundList>({
|
||||
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<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceRefundsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiCommerceRefundsListQueryKey(params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsList>>
|
||||
> = ({ signal }) => apiCommerceRefundsList(params, signal);
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiCommerceRefundsListQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsList>>
|
||||
>;
|
||||
export type ApiCommerceRefundsListQueryError = unknown;
|
||||
|
||||
export function useApiCommerceRefundsList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params: undefined | ApiCommerceRefundsListParams,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceRefundsList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceRefundsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceRefundsList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceRefundsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary List refunds (admin)
|
||||
*/
|
||||
|
||||
export function useApiCommerceRefundsList<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiCommerceRefundsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiCommerceRefundsListQueryOptions(params, options);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Create refund (admin)
|
||||
*/
|
||||
export const apiCommerceRefundsCreate = (
|
||||
refund: NonReadonly<Refund>,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<Refund>({
|
||||
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<ReturnType<typeof apiCommerceRefundsCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<Refund> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<Refund> },
|
||||
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<ReturnType<typeof apiCommerceRefundsCreate>>,
|
||||
{ data: NonReadonly<Refund> }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiCommerceRefundsCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceRefundsCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsCreate>>
|
||||
>;
|
||||
export type ApiCommerceRefundsCreateMutationBody = NonReadonly<Refund>;
|
||||
export type ApiCommerceRefundsCreateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Create refund (admin)
|
||||
*/
|
||||
export const useApiCommerceRefundsCreate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<Refund> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsCreate>>,
|
||||
TError,
|
||||
{ data: NonReadonly<Refund> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getApiCommerceRefundsCreateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve refund (admin)
|
||||
*/
|
||||
export const apiCommerceRefundsRetrieve = (
|
||||
id: number,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return privateMutator<Refund>({
|
||||
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<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiCommerceRefundsRetrieveQueryKey(id);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>
|
||||
> = ({ signal }) => apiCommerceRefundsRetrieve(id, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!id,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiCommerceRefundsRetrieveQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>
|
||||
>;
|
||||
export type ApiCommerceRefundsRetrieveQueryError = unknown;
|
||||
|
||||
export function useApiCommerceRefundsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceRefundsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiCommerceRefundsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve refund (admin)
|
||||
*/
|
||||
|
||||
export function useApiCommerceRefundsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiCommerceRefundsRetrieveQueryOptions(id, options);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Replace refund (admin)
|
||||
*/
|
||||
export const apiCommerceRefundsUpdate = (
|
||||
id: number,
|
||||
refund: NonReadonly<Refund>,
|
||||
) => {
|
||||
return privateMutator<Refund>({
|
||||
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<ReturnType<typeof apiCommerceRefundsUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<Refund> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<Refund> },
|
||||
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<ReturnType<typeof apiCommerceRefundsUpdate>>,
|
||||
{ id: number; data: NonReadonly<Refund> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiCommerceRefundsUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceRefundsUpdateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsUpdate>>
|
||||
>;
|
||||
export type ApiCommerceRefundsUpdateMutationBody = NonReadonly<Refund>;
|
||||
export type ApiCommerceRefundsUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Replace refund (admin)
|
||||
*/
|
||||
export const useApiCommerceRefundsUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<Refund> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<Refund> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getApiCommerceRefundsUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Update refund (admin)
|
||||
*/
|
||||
export const apiCommerceRefundsPartialUpdate = (
|
||||
id: number,
|
||||
patchedRefund: NonReadonly<PatchedRefund>,
|
||||
) => {
|
||||
return privateMutator<Refund>({
|
||||
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<ReturnType<typeof apiCommerceRefundsPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedRefund> },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedRefund> },
|
||||
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<ReturnType<typeof apiCommerceRefundsPartialUpdate>>,
|
||||
{ id: number; data: NonReadonly<PatchedRefund> }
|
||||
> = (props) => {
|
||||
const { id, data } = props ?? {};
|
||||
|
||||
return apiCommerceRefundsPartialUpdate(id, data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceRefundsPartialUpdateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsPartialUpdate>>
|
||||
>;
|
||||
export type ApiCommerceRefundsPartialUpdateMutationBody =
|
||||
NonReadonly<PatchedRefund>;
|
||||
export type ApiCommerceRefundsPartialUpdateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Update refund (admin)
|
||||
*/
|
||||
export const useApiCommerceRefundsPartialUpdate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedRefund> },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsPartialUpdate>>,
|
||||
TError,
|
||||
{ id: number; data: NonReadonly<PatchedRefund> },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiCommerceRefundsPartialUpdateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary Delete refund (admin)
|
||||
*/
|
||||
export const apiCommerceRefundsDestroy = (id: number) => {
|
||||
return privateMutator<void>({
|
||||
url: `/api/commerce/refunds/${id}/`,
|
||||
method: "DELETE",
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiCommerceRefundsDestroyMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsDestroy>>,
|
||||
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<ReturnType<typeof apiCommerceRefundsDestroy>>,
|
||||
{ id: number }
|
||||
> = (props) => {
|
||||
const { id } = props ?? {};
|
||||
|
||||
return apiCommerceRefundsDestroy(id);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiCommerceRefundsDestroyMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsDestroy>>
|
||||
>;
|
||||
|
||||
export type ApiCommerceRefundsDestroyMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Delete refund (admin)
|
||||
*/
|
||||
export const useApiCommerceRefundsDestroy = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiCommerceRefundsDestroy>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getApiCommerceRefundsDestroyMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
@@ -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<void>({
|
||||
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<ReturnType<typeof apiAccountPasswordResetCreate>>,
|
||||
TError,
|
||||
{ data: PasswordResetRequest },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountPasswordResetCreate>>,
|
||||
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<ReturnType<typeof apiAccountPasswordResetCreate>>,
|
||||
{ data: PasswordResetRequest }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiAccountPasswordResetCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAccountPasswordResetCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAccountPasswordResetCreate>>
|
||||
>;
|
||||
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<ReturnType<typeof apiAccountPasswordResetCreate>>,
|
||||
TError,
|
||||
{ data: PasswordResetRequest },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAccountPasswordResetCreate>>,
|
||||
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<void>({
|
||||
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<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
|
||||
TError,
|
||||
{ uidb64: string; token: string; data: PasswordResetConfirm },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
|
||||
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<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
|
||||
{ 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<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>
|
||||
>;
|
||||
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<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
|
||||
TError,
|
||||
{ uidb64: string; token: string; data: PasswordResetConfirm },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
|
||||
TError,
|
||||
{ uidb64: string; token: string; data: PasswordResetConfirm },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiAccountPasswordResetConfirmCreateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
@@ -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<UserRegistration>({
|
||||
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<ReturnType<typeof apiAccountRegisterCreate>>,
|
||||
TError,
|
||||
{ data: UserRegistration },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountRegisterCreate>>,
|
||||
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<ReturnType<typeof apiAccountRegisterCreate>>,
|
||||
{ data: UserRegistration }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiAccountRegisterCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAccountRegisterCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAccountRegisterCreate>>
|
||||
>;
|
||||
export type ApiAccountRegisterCreateMutationBody = UserRegistration;
|
||||
export type ApiAccountRegisterCreateMutationError = void;
|
||||
|
||||
/**
|
||||
* @summary Register a new user (company or individual)
|
||||
*/
|
||||
export const useApiAccountRegisterCreate = <TError = void, TContext = unknown>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountRegisterCreate>>,
|
||||
TError,
|
||||
{ data: UserRegistration },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAccountRegisterCreate>>,
|
||||
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<void>({
|
||||
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<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError = void,
|
||||
>(
|
||||
uidb64: string,
|
||||
token: string,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ??
|
||||
getApiAccountVerifyEmailRetrieveQueryKey(uidb64, token);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>
|
||||
> = ({ signal }) => apiAccountVerifyEmailRetrieve(uidb64, token, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!(uidb64 && token),
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiAccountVerifyEmailRetrieveQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>
|
||||
>;
|
||||
export type ApiAccountVerifyEmailRetrieveQueryError = void;
|
||||
|
||||
export function useApiAccountVerifyEmailRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError = void,
|
||||
>(
|
||||
uidb64: string,
|
||||
token: string,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiAccountVerifyEmailRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError = void,
|
||||
>(
|
||||
uidb64: string,
|
||||
token: string,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiAccountVerifyEmailRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError = void,
|
||||
>(
|
||||
uidb64: string,
|
||||
token: string,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Verify user email via link
|
||||
*/
|
||||
|
||||
export function useApiAccountVerifyEmailRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError = void,
|
||||
>(
|
||||
uidb64: string,
|
||||
token: string,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiAccountVerifyEmailRetrieveQueryOptions(
|
||||
uidb64,
|
||||
token,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
@@ -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<PaginatedZasilkovnaShipmentList>({
|
||||
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<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiZasilkovnaShipmentsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiZasilkovnaShipmentsListQueryKey(params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>
|
||||
> = ({ signal }) => apiZasilkovnaShipmentsList(params, signal);
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiZasilkovnaShipmentsListQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>
|
||||
>;
|
||||
export type ApiZasilkovnaShipmentsListQueryError = unknown;
|
||||
|
||||
export function useApiZasilkovnaShipmentsList<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params: undefined | ApiZasilkovnaShipmentsListParams,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiZasilkovnaShipmentsList<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiZasilkovnaShipmentsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiZasilkovnaShipmentsList<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiZasilkovnaShipmentsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Hromadný shipment
|
||||
*/
|
||||
|
||||
export function useApiZasilkovnaShipmentsList<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiZasilkovnaShipmentsListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiZasilkovnaShipmentsListQueryOptions(
|
||||
params,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
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<ZasilkovnaShipment>({
|
||||
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<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getApiZasilkovnaShipmentsRetrieveQueryKey(id);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>
|
||||
> = ({ signal }) => apiZasilkovnaShipmentsRetrieve(id, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!id,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiZasilkovnaShipmentsRetrieveQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>
|
||||
>;
|
||||
export type ApiZasilkovnaShipmentsRetrieveQueryError = unknown;
|
||||
|
||||
export function useApiZasilkovnaShipmentsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiZasilkovnaShipmentsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiZasilkovnaShipmentsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Detail hromadné zásilky
|
||||
*/
|
||||
|
||||
export function useApiZasilkovnaShipmentsRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiZasilkovnaShipmentsRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiZasilkovnaShipmentsRetrieveQueryOptions(
|
||||
id,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
706
frontend/src/api/generated/public/account.ts
Normal file
706
frontend/src/api/generated/public/account.ts
Normal file
@@ -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<CustomTokenObtainPair>({
|
||||
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<ReturnType<typeof apiAccountLoginCreate>>,
|
||||
TError,
|
||||
{ data: CustomTokenObtainPair },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountLoginCreate>>,
|
||||
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<ReturnType<typeof apiAccountLoginCreate>>,
|
||||
{ data: CustomTokenObtainPair }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiAccountLoginCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAccountLoginCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAccountLoginCreate>>
|
||||
>;
|
||||
export type ApiAccountLoginCreateMutationBody = CustomTokenObtainPair;
|
||||
export type ApiAccountLoginCreateMutationError = void;
|
||||
|
||||
/**
|
||||
* @summary Obtain JWT access and refresh tokens (cookie-based)
|
||||
*/
|
||||
export const useApiAccountLoginCreate = <TError = void, TContext = unknown>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountLoginCreate>>,
|
||||
TError,
|
||||
{ data: CustomTokenObtainPair },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAccountLoginCreate>>,
|
||||
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<void>({
|
||||
url: `/api/account/logout/`,
|
||||
method: "POST",
|
||||
signal,
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiAccountLogoutCreateMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
||||
TError,
|
||||
void,
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
||||
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<ReturnType<typeof apiAccountLogoutCreate>>,
|
||||
void
|
||||
> = () => {
|
||||
return apiAccountLogoutCreate();
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAccountLogoutCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAccountLogoutCreate>>
|
||||
>;
|
||||
|
||||
export type ApiAccountLogoutCreateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Logout user (delete access and refresh token cookies)
|
||||
*/
|
||||
export const useApiAccountLogoutCreate = <TError = unknown, TContext = unknown>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
||||
TError,
|
||||
void,
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
||||
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<void>({
|
||||
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<ReturnType<typeof apiAccountPasswordResetCreate>>,
|
||||
TError,
|
||||
{ data: PasswordResetRequest },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountPasswordResetCreate>>,
|
||||
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<ReturnType<typeof apiAccountPasswordResetCreate>>,
|
||||
{ data: PasswordResetRequest }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiAccountPasswordResetCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAccountPasswordResetCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAccountPasswordResetCreate>>
|
||||
>;
|
||||
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<ReturnType<typeof apiAccountPasswordResetCreate>>,
|
||||
TError,
|
||||
{ data: PasswordResetRequest },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAccountPasswordResetCreate>>,
|
||||
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<void>({
|
||||
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<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
|
||||
TError,
|
||||
{ uidb64: string; token: string; data: PasswordResetConfirm },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
|
||||
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<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
|
||||
{ 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<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>
|
||||
>;
|
||||
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<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
|
||||
TError,
|
||||
{ uidb64: string; token: string; data: PasswordResetConfirm },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
|
||||
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<UserRegistration>({
|
||||
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<ReturnType<typeof apiAccountRegisterCreate>>,
|
||||
TError,
|
||||
{ data: UserRegistration },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountRegisterCreate>>,
|
||||
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<ReturnType<typeof apiAccountRegisterCreate>>,
|
||||
{ data: UserRegistration }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiAccountRegisterCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAccountRegisterCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAccountRegisterCreate>>
|
||||
>;
|
||||
export type ApiAccountRegisterCreateMutationBody = UserRegistration;
|
||||
export type ApiAccountRegisterCreateMutationError = void;
|
||||
|
||||
/**
|
||||
* @summary Register a new user (company or individual)
|
||||
*/
|
||||
export const useApiAccountRegisterCreate = <TError = void, TContext = unknown>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountRegisterCreate>>,
|
||||
TError,
|
||||
{ data: UserRegistration },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAccountRegisterCreate>>,
|
||||
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<void>({
|
||||
url: `/api/account/token/refresh/`,
|
||||
method: "POST",
|
||||
signal,
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiAccountTokenRefreshCreateMutationOptions = <
|
||||
TError = void,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
||||
TError,
|
||||
void,
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
||||
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<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
||||
void
|
||||
> = () => {
|
||||
return apiAccountTokenRefreshCreate();
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAccountTokenRefreshCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>
|
||||
>;
|
||||
|
||||
export type ApiAccountTokenRefreshCreateMutationError = void;
|
||||
|
||||
/**
|
||||
* @summary Refresh JWT token using cookie
|
||||
*/
|
||||
export const useApiAccountTokenRefreshCreate = <
|
||||
TError = void,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
||||
TError,
|
||||
void,
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
||||
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<void>({
|
||||
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<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError = void,
|
||||
>(
|
||||
uidb64: string,
|
||||
token: string,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ??
|
||||
getApiAccountVerifyEmailRetrieveQueryKey(uidb64, token);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>
|
||||
> = ({ signal }) => apiAccountVerifyEmailRetrieve(uidb64, token, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!(uidb64 && token),
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiAccountVerifyEmailRetrieveQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>
|
||||
>;
|
||||
export type ApiAccountVerifyEmailRetrieveQueryError = void;
|
||||
|
||||
export function useApiAccountVerifyEmailRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError = void,
|
||||
>(
|
||||
uidb64: string,
|
||||
token: string,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiAccountVerifyEmailRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError = void,
|
||||
>(
|
||||
uidb64: string,
|
||||
token: string,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiAccountVerifyEmailRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError = void,
|
||||
>(
|
||||
uidb64: string,
|
||||
token: string,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Verify user email via link
|
||||
*/
|
||||
|
||||
export function useApiAccountVerifyEmailRetrieve<
|
||||
TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError = void,
|
||||
>(
|
||||
uidb64: string,
|
||||
token: string,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getApiAccountVerifyEmailRetrieveQueryOptions(
|
||||
uidb64,
|
||||
token,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
88
frontend/src/api/generated/public/advertisement.ts
Normal file
88
frontend/src/api/generated/public/advertisement.ts
Normal file
@@ -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<void>({
|
||||
url: `/api/advertisement/contact-me/`,
|
||||
method: "POST",
|
||||
signal,
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiAdvertisementContactMeCreateMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMeCreate>>,
|
||||
TError,
|
||||
void,
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMeCreate>>,
|
||||
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<ReturnType<typeof apiAdvertisementContactMeCreate>>,
|
||||
void
|
||||
> = () => {
|
||||
return apiAdvertisementContactMeCreate();
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAdvertisementContactMeCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMeCreate>>
|
||||
>;
|
||||
|
||||
export type ApiAdvertisementContactMeCreateMutationError = unknown;
|
||||
|
||||
export const useApiAdvertisementContactMeCreate = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMeCreate>>,
|
||||
TError,
|
||||
void,
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAdvertisementContactMeCreate>>,
|
||||
TError,
|
||||
void,
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiAdvertisementContactMeCreateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
@@ -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<CustomTokenObtainPair>({
|
||||
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<ReturnType<typeof apiAccountLoginCreate>>,
|
||||
TError,
|
||||
{ data: CustomTokenObtainPair },
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountLoginCreate>>,
|
||||
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<ReturnType<typeof apiAccountLoginCreate>>,
|
||||
{ data: CustomTokenObtainPair }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
|
||||
return apiAccountLoginCreate(data);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAccountLoginCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAccountLoginCreate>>
|
||||
>;
|
||||
export type ApiAccountLoginCreateMutationBody = CustomTokenObtainPair;
|
||||
export type ApiAccountLoginCreateMutationError = void;
|
||||
|
||||
/**
|
||||
* @summary Obtain JWT access and refresh tokens (cookie-based)
|
||||
*/
|
||||
export const useApiAccountLoginCreate = <TError = void, TContext = unknown>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountLoginCreate>>,
|
||||
TError,
|
||||
{ data: CustomTokenObtainPair },
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAccountLoginCreate>>,
|
||||
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<void>({
|
||||
url: `/api/account/logout/`,
|
||||
method: "POST",
|
||||
signal,
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiAccountLogoutCreateMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
||||
TError,
|
||||
void,
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
||||
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<ReturnType<typeof apiAccountLogoutCreate>>,
|
||||
void
|
||||
> = () => {
|
||||
return apiAccountLogoutCreate();
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAccountLogoutCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAccountLogoutCreate>>
|
||||
>;
|
||||
|
||||
export type ApiAccountLogoutCreateMutationError = unknown;
|
||||
|
||||
/**
|
||||
* @summary Logout user (delete access and refresh token cookies)
|
||||
*/
|
||||
export const useApiAccountLogoutCreate = <TError = unknown, TContext = unknown>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
||||
TError,
|
||||
void,
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
||||
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<void>({
|
||||
url: `/api/account/token/refresh/`,
|
||||
method: "POST",
|
||||
signal,
|
||||
});
|
||||
};
|
||||
|
||||
export const getApiAccountTokenRefreshCreateMutationOptions = <
|
||||
TError = void,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
||||
TError,
|
||||
void,
|
||||
TContext
|
||||
>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
||||
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<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
||||
void
|
||||
> = () => {
|
||||
return apiAccountTokenRefreshCreate();
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type ApiAccountTokenRefreshCreateMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>
|
||||
>;
|
||||
|
||||
export type ApiAccountTokenRefreshCreateMutationError = void;
|
||||
|
||||
/**
|
||||
* @summary Refresh JWT token using cookie
|
||||
*/
|
||||
export const useApiAccountTokenRefreshCreate = <
|
||||
TError = void,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
||||
TError,
|
||||
void,
|
||||
TContext
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
||||
TError,
|
||||
void,
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions =
|
||||
getApiAccountTokenRefreshCreateMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
1767
frontend/src/api/generated/public/commerce.ts
Normal file
1767
frontend/src/api/generated/public/commerce.ts
Normal file
File diff suppressed because it is too large
Load Diff
408
frontend/src/api/generated/public/configuration.ts
Normal file
408
frontend/src/api/generated/public/configuration.ts
Normal file
@@ -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<PaginatedSiteConfigurationPublicList>({
|
||||
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<typeof apiConfigurationPublicShopConfigurationList>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiConfigurationPublicShopConfigurationListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ??
|
||||
getApiConfigurationPublicShopConfigurationListQueryKey(params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationList>>
|
||||
> = ({ signal }) =>
|
||||
apiConfigurationPublicShopConfigurationList(params, signal);
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationList>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiConfigurationPublicShopConfigurationListQueryResult =
|
||||
NonNullable<
|
||||
Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationList>>
|
||||
>;
|
||||
export type ApiConfigurationPublicShopConfigurationListQueryError = unknown;
|
||||
|
||||
export function useApiConfigurationPublicShopConfigurationList<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationList>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params: undefined | ApiConfigurationPublicShopConfigurationListParams,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationList>
|
||||
>,
|
||||
TError,
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationList>
|
||||
>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiConfigurationPublicShopConfigurationList<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationList>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiConfigurationPublicShopConfigurationListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationList>
|
||||
>,
|
||||
TError,
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationList>
|
||||
>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiConfigurationPublicShopConfigurationList<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationList>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiConfigurationPublicShopConfigurationListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary List site configuration (public)
|
||||
*/
|
||||
|
||||
export function useApiConfigurationPublicShopConfigurationList<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationList>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
params?: ApiConfigurationPublicShopConfigurationListParams,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationList>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions =
|
||||
getApiConfigurationPublicShopConfigurationListQueryOptions(params, options);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Retrieve site configuration (public)
|
||||
*/
|
||||
export const apiConfigurationPublicShopConfigurationRetrieve = (
|
||||
id: number,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return publicMutator<SiteConfigurationPublic>({
|
||||
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<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ??
|
||||
getApiConfigurationPublicShopConfigurationRetrieveQueryKey(id);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>>
|
||||
> = ({ signal }) =>
|
||||
apiConfigurationPublicShopConfigurationRetrieve(id, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: !!id,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
export type ApiConfigurationPublicShopConfigurationRetrieveQueryResult =
|
||||
NonNullable<
|
||||
Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>>
|
||||
>;
|
||||
export type ApiConfigurationPublicShopConfigurationRetrieveQueryError = unknown;
|
||||
|
||||
export function useApiConfigurationPublicShopConfigurationRetrieve<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiConfigurationPublicShopConfigurationRetrieve<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useApiConfigurationPublicShopConfigurationRetrieve<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
/**
|
||||
* @summary Retrieve site configuration (public)
|
||||
*/
|
||||
|
||||
export function useApiConfigurationPublicShopConfigurationRetrieve<
|
||||
TData = Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>,
|
||||
TError = unknown,
|
||||
>(
|
||||
id: number,
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<
|
||||
ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>
|
||||
>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions =
|
||||
getApiConfigurationPublicShopConfigurationRetrieveQueryOptions(id, options);
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
|
||||
return query;
|
||||
}
|
||||
@@ -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 = (
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -6,5 +6,4 @@
|
||||
|
||||
export interface DownloadErrorResponse {
|
||||
error: string;
|
||||
allowed?: string[];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
*/
|
||||
|
||||
export interface ErrorResponse {
|
||||
/** Error message describing what went wrong */
|
||||
error: string;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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";
|
||||
|
||||
@@ -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[];
|
||||
}
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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 <T>(
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 | VideoInfoResponse>(null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isDownloading, setIsDownloading] = useState(false);
|
||||
const [error, setError] = useState<null | { error: string }>(null);
|
||||
|
||||
async function retriveVideoInfo() {
|
||||
// Basic download options
|
||||
const [selectedVideoQuality, setSelectedVideoQuality] = useState<string>('');
|
||||
const [selectedAudioQuality, setSelectedAudioQuality] = useState<string>('');
|
||||
const [selectedExtension, setSelectedExtension] = useState<string>('mp4');
|
||||
|
||||
// Advanced options
|
||||
const [subtitles, setSubtitles] = useState<string>('');
|
||||
const [embedSubtitles, setEmbedSubtitles] = useState<boolean>(false);
|
||||
const [embedThumbnail, setEmbedThumbnail] = useState<boolean>(false);
|
||||
const [extractAudio, setExtractAudio] = useState<boolean>(false);
|
||||
const [startTime, setStartTime] = useState<string>('');
|
||||
const [endTime, setEndTime] = useState<string>('');
|
||||
const [playlistItems, setPlaylistItems] = useState<string>('');
|
||||
const [cookies, setCookies] = useState<string>('');
|
||||
const [showAdvanced, setShowAdvanced] = useState<boolean>(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 (
|
||||
<div className="p-6">
|
||||
<div className="p-6 max-w-4xl mx-auto">
|
||||
<h1 className="text-2xl font-bold mb-4">Video Downloader</h1>
|
||||
|
||||
<div className="mb-4">
|
||||
<input
|
||||
type="text"
|
||||
value={videoUrl}
|
||||
onChange={(e) => setVideoUrl(e.target.value)}
|
||||
placeholder="Paste video URL here"
|
||||
className="w-full p-2 border rounded mb-4"
|
||||
placeholder="Paste video URL here (YouTube, TikTok, Vimeo, etc.)"
|
||||
className="w-full p-2 border rounded"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button onClick={retriveVideoInfo}>Retrieve options</button>
|
||||
<button
|
||||
onClick={retrieveVideoInfo}
|
||||
disabled={isLoading || !videoUrl}
|
||||
className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:bg-gray-300 disabled:cursor-not-allowed"
|
||||
>
|
||||
{isLoading ? 'Loading...' : 'Retrieve Options'}
|
||||
</button>
|
||||
|
||||
{isLoading && <p>Loading video info...</p>}
|
||||
|
||||
{error && <p className="text-red-500">Error: {error?.error}</p>}
|
||||
{error && (
|
||||
<div className="mt-4 p-4 bg-red-100 text-red-700 rounded">
|
||||
Error: {error.error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{videoInfo && (
|
||||
<div className="mt-4">
|
||||
<h2 className="text-xl font-semibold">{videoInfo.title}</h2>
|
||||
<div className="mt-6 p-4 border rounded">
|
||||
<h2 className="text-xl font-semibold mb-2">{videoInfo.title}</h2>
|
||||
|
||||
{videoInfo.thumbnail && (
|
||||
<img src={videoInfo.thumbnail} alt={videoInfo.title} className="mt-2 max-w-md" />
|
||||
<img
|
||||
src={videoInfo.thumbnail}
|
||||
alt={videoInfo.title}
|
||||
className="mt-2 max-w-md rounded shadow"
|
||||
/>
|
||||
)}
|
||||
<p className="mt-2">Duration: {videoInfo.duration}s</p>
|
||||
|
||||
<h3 className="mt-4 font-semibold">Available Video Qualities:</h3>
|
||||
<ul>
|
||||
{videoInfo.duration && (
|
||||
<p className="mt-2 text-gray-600">
|
||||
Duration: {Math.floor(videoInfo.duration / 60)}:{String(videoInfo.duration % 60).padStart(2, '0')}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="mt-6 grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
{/* Video Quality Dropdown */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-2">
|
||||
Video Quality (optional)
|
||||
</label>
|
||||
<select
|
||||
value={selectedVideoQuality}
|
||||
onChange={(e) => setSelectedVideoQuality(e.target.value)}
|
||||
className="w-full p-2 border rounded"
|
||||
>
|
||||
<option value="">Best available</option>
|
||||
{videoInfo.video_resolutions?.map((res) => (
|
||||
<li key={res}>{res}</li>
|
||||
<option key={res} value={res}>{res}</option>
|
||||
))}
|
||||
</ul>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<h3 className="mt-4 font-semibold">Available Audio Qualities:</h3>
|
||||
<ul>
|
||||
{/* Audio Quality Dropdown */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-2">
|
||||
Audio Quality (optional)
|
||||
</label>
|
||||
<select
|
||||
value={selectedAudioQuality}
|
||||
onChange={(e) => setSelectedAudioQuality(e.target.value)}
|
||||
className="w-full p-2 border rounded"
|
||||
>
|
||||
<option value="">Best available</option>
|
||||
{videoInfo.audio_resolutions?.map((res) => (
|
||||
<li key={res}>{res}</li>
|
||||
<option key={res} value={res}>{res}</option>
|
||||
))}
|
||||
</ul>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* File Extension Dropdown */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-2">
|
||||
File Format
|
||||
</label>
|
||||
<select
|
||||
value={selectedExtension}
|
||||
onChange={(e) => setSelectedExtension(e.target.value)}
|
||||
className="w-full p-2 border rounded"
|
||||
>
|
||||
{FILE_EXTENSIONS.map((ext) => (
|
||||
<option key={ext.value} value={ext.value}>
|
||||
{ext.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={handleDownload}
|
||||
disabled={isDownloading}
|
||||
className="mt-6 px-6 py-3 bg-green-500 text-white rounded hover:bg-green-600 disabled:bg-gray-300 disabled:cursor-not-allowed"
|
||||
>
|
||||
{isDownloading ? 'Downloading...' : 'Download'}
|
||||
</button>
|
||||
|
||||
{/* Advanced Options Toggle */}
|
||||
<div className="mt-8 border-t pt-6">
|
||||
<button
|
||||
onClick={() => setShowAdvanced(!showAdvanced)}
|
||||
className="text-blue-500 hover:text-blue-700 font-medium flex items-center gap-2"
|
||||
>
|
||||
{showAdvanced ? '▼' : '▶'} Advanced Options
|
||||
</button>
|
||||
|
||||
{showAdvanced && (
|
||||
<div className="mt-4 space-y-4 p-4 bg-gray-50 rounded">
|
||||
{/* Subtitles */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-2">
|
||||
Subtitles (optional)
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={subtitles}
|
||||
onChange={(e) => setSubtitles(e.target.value)}
|
||||
placeholder="e.g., 'en', 'en,cs', or 'all'"
|
||||
className="w-full p-2 border rounded"
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-1">
|
||||
Language codes (e.g., 'en', 'cs') or 'all' for all available
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Checkboxes Row */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<label className="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={embedSubtitles}
|
||||
onChange={(e) => setEmbedSubtitles(e.target.checked)}
|
||||
className="w-4 h-4"
|
||||
/>
|
||||
<span className="text-sm">Embed Subtitles (mkv/mp4 only)</span>
|
||||
</label>
|
||||
|
||||
<label className="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={embedThumbnail}
|
||||
onChange={(e) => setEmbedThumbnail(e.target.checked)}
|
||||
className="w-4 h-4"
|
||||
/>
|
||||
<span className="text-sm">Embed Thumbnail</span>
|
||||
</label>
|
||||
|
||||
<label className="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={extractAudio}
|
||||
onChange={(e) => setExtractAudio(e.target.checked)}
|
||||
className="w-4 h-4"
|
||||
/>
|
||||
<span className="text-sm">Audio Only</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{/* Trim Times */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-2">
|
||||
Start Time (trim)
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={startTime}
|
||||
onChange={(e) => setStartTime(e.target.value)}
|
||||
placeholder="e.g., 00:01:30 or 90"
|
||||
className="w-full p-2 border rounded"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-2">
|
||||
End Time (trim)
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={endTime}
|
||||
onChange={(e) => setEndTime(e.target.value)}
|
||||
placeholder="e.g., 00:05:00 or 300"
|
||||
className="w-full p-2 border rounded"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Playlist Items */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-2">
|
||||
Playlist Items (optional)
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={playlistItems}
|
||||
onChange={(e) => setPlaylistItems(e.target.value)}
|
||||
placeholder="e.g., '1-5,8,10' or '1,2,3'"
|
||||
className="w-full p-2 border rounded"
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-1">
|
||||
Specify which playlist items to download (e.g., '1-5,8,10')
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Cookies for Age-Restricted Content */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-2">
|
||||
Cookies (for age-restricted content)
|
||||
</label>
|
||||
<textarea
|
||||
value={cookies}
|
||||
onChange={(e) => setCookies(e.target.value)}
|
||||
placeholder="Paste cookies in Netscape format here..."
|
||||
rows={4}
|
||||
className="w-full p-2 border rounded font-mono text-xs"
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-1">
|
||||
Export cookies from your browser using extensions like "Get cookies.txt" or "cookies.txt".
|
||||
Login to YouTube/Google first, then export cookies in Netscape format.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user