diff --git a/packages/thunderstore-api/src/apiFetch.ts b/packages/thunderstore-api/src/apiFetch.ts index 2125c3c77..2db2b648f 100644 --- a/packages/thunderstore-api/src/apiFetch.ts +++ b/packages/thunderstore-api/src/apiFetch.ts @@ -44,29 +44,33 @@ function sleep(delay: number) { return new Promise((resolve) => setTimeout(resolve, delay)); } -export type apiFetchArgs = { +type SchemaOrUndefined = + Schema extends z.ZodSchema ? z.infer : undefined; + +type apiFetchArgs< + RequestSchema extends z.ZodSchema | undefined, + QueryParamsSchema extends z.ZodSchema | undefined, + ResponseSchema extends z.ZodSchema | undefined, +> = { config: () => RequestConfig; path: string; - queryParams?: QP; + queryParams?: SchemaOrUndefined; request?: Omit & { body?: string }; useSession?: boolean; - bodyRaw?: B; + bodyRaw?: SchemaOrUndefined; + requestSchema: RequestSchema; + queryParamsSchema: QueryParamsSchema; + responseSchema: ResponseSchema; }; -type schemaOrUndefined = A extends z.ZodSchema - ? z.infer - : never | undefined; - -export async function apiFetch(props: { - args: apiFetchArgs< - schemaOrUndefined, - schemaOrUndefined - >; - requestSchema: z.ZodSchema | undefined; - queryParamsSchema: z.ZodSchema | undefined; - responseSchema: z.ZodSchema | undefined; -}): Promise> { - const { args, requestSchema, queryParamsSchema, responseSchema } = props; +export async function apiFetch< + RequestSchema extends z.ZodSchema | undefined, + QueryParamsSchema extends z.ZodSchema | undefined, + ResponseSchema extends z.ZodSchema | undefined, +>( + args: apiFetchArgs +): Promise> { + const { requestSchema, queryParamsSchema, responseSchema } = args; if (requestSchema && args.bodyRaw) { const parsedRequestBody = requestSchema.safeParse(args.bodyRaw); @@ -74,6 +78,7 @@ export async function apiFetch(props: { throw new RequestBodyParseError(parsedRequestBody.error); } } + if (queryParamsSchema && args.queryParams) { const parsedQueryParams = queryParamsSchema.safeParse(args.queryParams); if (!parsedQueryParams.success) { @@ -88,8 +93,7 @@ export async function apiFetch(props: { apiHost: config().apiHost, sessionId: undefined, }; - // TODO: Query params have stronger types, but they are not just shown here. - // Look into furthering the ensuring of passing proper query params. + const sessionWasUsed = Boolean(usedConfig.sessionId); const url = getUrl(usedConfig, path, queryParams); const response = await fetchRetry(url, { @@ -101,17 +105,21 @@ export async function apiFetch(props: { }); if (!response.ok) { - throw await ApiError.createFromResponse(response); + throw await ApiError.createFromResponse(response, { + sessionWasUsed, + }); } - if (responseSchema === undefined) return undefined; + if (responseSchema === undefined) { + return undefined as SchemaOrUndefined; + } const parsed = responseSchema.safeParse(await response.json()); if (!parsed.success) { throw new ParseError(parsed.error); - } else { - return parsed.data; } + + return parsed.data; } function getAuthHeaders(config: RequestConfig): RequestInit["headers"] { diff --git a/packages/thunderstore-api/src/delete/packageWiki.ts b/packages/thunderstore-api/src/delete/packageWiki.ts index 9e8d4d2cc..7fa678583 100644 --- a/packages/thunderstore-api/src/delete/packageWiki.ts +++ b/packages/thunderstore-api/src/delete/packageWiki.ts @@ -6,7 +6,7 @@ import { packageWikiPageDeleteRequestDataSchema, } from "../schemas/requestSchemas"; -export async function deletePackageWikiPage( +export function deletePackageWikiPage( props: ApiEndpointProps< PackageWikiPageDeleteRequestParams, object, @@ -16,15 +16,13 @@ export async function deletePackageWikiPage( const { config, params, data } = props; const path = `api/experimental/package/${params.namespace_id}/${params.package_name}/wiki/`; - return await apiFetch({ - args: { - config: config, - path: path, - request: { - method: "DELETE", - cache: "no-store", - body: JSON.stringify(data), - }, + return apiFetch({ + config: config, + path: path, + request: { + method: "DELETE", + cache: "no-store", + body: JSON.stringify(data), }, requestSchema: packageWikiPageDeleteRequestDataSchema, queryParamsSchema: undefined, diff --git a/packages/thunderstore-api/src/delete/teamDisband.ts b/packages/thunderstore-api/src/delete/teamDisband.ts index 2ca1d4e20..e2a61cff8 100644 --- a/packages/thunderstore-api/src/delete/teamDisband.ts +++ b/packages/thunderstore-api/src/delete/teamDisband.ts @@ -9,14 +9,12 @@ export function teamDisband( const path = `/api/cyberstorm/team/${params.team_name}/disband/`; return apiFetch({ - args: { - config, - path, - request: { - method: "DELETE", - }, - useSession: true, + config, + path, + request: { + method: "DELETE", }, + useSession: true, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: undefined, diff --git a/packages/thunderstore-api/src/delete/teamRemoveMember.ts b/packages/thunderstore-api/src/delete/teamRemoveMember.ts index 55e8826ac..127c46579 100644 --- a/packages/thunderstore-api/src/delete/teamRemoveMember.ts +++ b/packages/thunderstore-api/src/delete/teamRemoveMember.ts @@ -11,14 +11,12 @@ export function teamRemoveMember( const path = `/api/cyberstorm/team/${params.team_name}/member/${params.username}/remove/`; return apiFetch({ - args: { - config, - path, - request: { - method: "DELETE", - }, - useSession: true, + config, + path, + request: { + method: "DELETE", }, + useSession: true, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: undefined, diff --git a/packages/thunderstore-api/src/delete/teamServiceAccountRemove.ts b/packages/thunderstore-api/src/delete/teamServiceAccountRemove.ts index 852c8aa09..e53888647 100644 --- a/packages/thunderstore-api/src/delete/teamServiceAccountRemove.ts +++ b/packages/thunderstore-api/src/delete/teamServiceAccountRemove.ts @@ -11,14 +11,12 @@ export function teamServiceAccountRemove( const path = `/api/cyberstorm/service-account/${params.uuid}/delete/`; return apiFetch({ - args: { - config, - path, - request: { - method: "DELETE", - }, - useSession: true, + config, + path, + request: { + method: "DELETE", }, + useSession: true, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: undefined, diff --git a/packages/thunderstore-api/src/delete/userDelete.ts b/packages/thunderstore-api/src/delete/userDelete.ts index e0fc78fb4..9ef6e27e1 100644 --- a/packages/thunderstore-api/src/delete/userDelete.ts +++ b/packages/thunderstore-api/src/delete/userDelete.ts @@ -8,14 +8,12 @@ export function userDelete( const path = `/api/cyberstorm/user/delete/`; return apiFetch({ - args: { - config, - path, - request: { - method: "DELETE", - }, - useSession: true, + config, + path, + request: { + method: "DELETE", }, + useSession: true, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: undefined, diff --git a/packages/thunderstore-api/src/delete/userLinkedAccountDisconnect.ts b/packages/thunderstore-api/src/delete/userLinkedAccountDisconnect.ts index bd88b530d..f4d103bde 100644 --- a/packages/thunderstore-api/src/delete/userLinkedAccountDisconnect.ts +++ b/packages/thunderstore-api/src/delete/userLinkedAccountDisconnect.ts @@ -16,14 +16,12 @@ export function userLinkedAccountDisconnect( const path = `/api/cyberstorm/user/linked-account/${params.provider}/disconnect/`; return apiFetch({ - args: { - config, - path, - request: { - method: "DELETE", - }, - useSession: true, + config, + path, + request: { + method: "DELETE", }, + useSession: true, requestSchema: userLinkedAccountDisconnectRequestDataSchema, queryParamsSchema: undefined, responseSchema: undefined, diff --git a/packages/thunderstore-api/src/errors.ts b/packages/thunderstore-api/src/errors.ts index 48e2d6029..16c6fef39 100644 --- a/packages/thunderstore-api/src/errors.ts +++ b/packages/thunderstore-api/src/errors.ts @@ -1,11 +1,30 @@ import { z } from "zod"; +import { sanitizeServerDetail } from "./errors/sanitizeServerDetail"; +import { formatErrorMessage } from "./utils"; + type JSONValue = | string | number | boolean | { [x: string]: JSONValue } - | JSONValue[]; + | JSONValue[] + | null; + +type ApiErrorContext = { + sessionWasUsed?: boolean; +}; + +const JSON_MESSAGE_PRIORITY_KEYS = [ + "detail", + "message", + "error", + "errors", + "non_field_errors", + "root", + "__all__", + "title", +]; export function isApiError(e: Error | ApiError | unknown): e is ApiError { return e instanceof ApiError; @@ -14,69 +33,173 @@ export function isApiError(e: Error | ApiError | unknown): e is ApiError { export class ApiError extends Error { response: Response; responseJson?: JSONValue; + responseText?: string; + context?: ApiErrorContext; + responseSummary?: string; constructor(args: { message: string; response: Response; responseJson?: JSONValue; + responseText?: string; + context?: ApiErrorContext; + responseSummary?: string; }) { super(args.message); this.responseJson = args.responseJson; this.response = args.response; + this.responseText = args.responseText; + this.context = args.context; + this.responseSummary = args.responseSummary; } - static async createFromResponse(response: Response): Promise { + static async createFromResponse( + response: Response, + context: ApiErrorContext = {} + ): Promise { + let responseText: string | undefined; let responseJson: JSONValue | undefined; try { - responseJson = await response.json(); + responseText = await response.clone().text(); + } catch { + responseText = undefined; + } + try { + responseJson = responseText + ? JSON.parse(responseText) + : await response.json(); // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (e) { responseJson = undefined; } + const responseSummary = extractMessage(responseJson ?? responseText); + return new ApiError({ - message: `${response.status}: ${response.statusText}`, + message: buildApiErrorMessage({ response, responseJson }), response: response, responseJson: responseJson, + responseText, + context, + responseSummary, }); } getFieldErrors(): { [key: string | "root"]: string[] } { - if (typeof this.responseJson !== "object") + if (!this.responseJson || typeof this.responseJson !== "object") return { root: ["Unknown error occurred"] }; if (Array.isArray(this.responseJson)) { return { - root: this.responseJson.map((x) => x.toString()), + root: this.responseJson.map((x) => String(x)), }; } else { return Object.fromEntries( Object.entries(this.responseJson).map(([key, val]) => { return [ key, - Array.isArray(val) - ? val.map((x) => x.toString()) - : [val.toString()], + Array.isArray(val) ? val.map((x) => String(x)) : [String(val)], ]; }) ); } } + + get statusCode(): number { + return this.response.status; + } + + get statusText(): string { + return this.response.statusText; + } } +/** + * Raised when a request body fails validation against its Zod schema. + */ export class RequestBodyParseError extends Error { constructor(public error: z.ZodError) { - super(error.message); + super(formatErrorMessage(error)); } } +/** + * Raised when query parameters fail validation against their Zod schema. + */ export class RequestQueryParamsParseError extends Error { constructor(public error: z.ZodError) { - super(error.message); + super(formatErrorMessage(error)); } } +/** + * Raised when response payloads fail validation against their expected Zod schema. + */ export class ParseError extends Error { constructor(public error: z.ZodError) { - super(error.message); + super(formatErrorMessage(error)); + } +} + +function buildApiErrorMessage(args: { + response: Response; + responseJson?: JSONValue; +}): string { + const { response, responseJson } = args; + const statusLabel = getStatusLabel(response); + const detailMessage = extractMessage(responseJson); + + if (detailMessage) { + return `${detailMessage} (${statusLabel})`; + } + + return statusLabel; +} + +function extractMessage(value: JSONValue | undefined): string | undefined { + if (value === undefined || value === null) return undefined; + + if (typeof value === "string") { + return sanitizeServerDetail(value); + } + + if (typeof value === "number" || typeof value === "boolean") { + return sanitizeServerDetail(String(value)); + } + + if (Array.isArray(value)) { + const parts = value + .map((item) => extractMessage(item)) + .filter((item): item is string => Boolean(item)); + + if (parts.length > 0) { + return sanitizeServerDetail(parts.join(" ")); + } + + return undefined; } + + const objectValue = value as { [x: string]: JSONValue }; + + for (const key of JSON_MESSAGE_PRIORITY_KEYS) { + if (key in objectValue) { + const message = extractMessage(objectValue[key]); + if (message) { + return sanitizeServerDetail(message); + } + } + } + + for (const entry of Object.values(objectValue)) { + const message = extractMessage(entry); + if (message) { + return message; + } + } + + return undefined; +} + +function getStatusLabel(response: Response): string { + const statusText = response.statusText?.trim() || "Error"; + return `${response.status} ${statusText}`.trim(); } diff --git a/packages/thunderstore-api/src/get/__tests__/teamMembers.test.ts b/packages/thunderstore-api/src/get/__tests__/teamMembers.test.ts index f41d3bce9..3618c2425 100644 --- a/packages/thunderstore-api/src/get/__tests__/teamMembers.test.ts +++ b/packages/thunderstore-api/src/get/__tests__/teamMembers.test.ts @@ -11,5 +11,5 @@ it("ensures accessing team members requires authentication", async () => { data: {}, queryParams: {}, }) - ).rejects.toThrowError("401: Unauthorized"); + ).rejects.toThrowError("Authentication required. Please sign in."); }); diff --git a/packages/thunderstore-api/src/get/__tests__/teamServiceAccounts.test.ts b/packages/thunderstore-api/src/get/__tests__/teamServiceAccounts.test.ts index 2308fdf71..2e4bd163c 100644 --- a/packages/thunderstore-api/src/get/__tests__/teamServiceAccounts.test.ts +++ b/packages/thunderstore-api/src/get/__tests__/teamServiceAccounts.test.ts @@ -11,5 +11,5 @@ it("ensures accessing team members requires authentication", async () => { data: {}, queryParams: {}, }) - ).rejects.toThrowError("401: Unauthorized"); + ).rejects.toThrowError("Authentication required. Please sign in."); }); diff --git a/packages/thunderstore-api/src/get/community.ts b/packages/thunderstore-api/src/get/community.ts index 37e712ec9..d10d2c039 100644 --- a/packages/thunderstore-api/src/get/community.ts +++ b/packages/thunderstore-api/src/get/community.ts @@ -6,17 +6,15 @@ import { communityResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchCommunity( +export function fetchCommunity( props: ApiEndpointProps ): Promise { const { config, params } = props; const path = `api/cyberstorm/community/${params.community_id}/`; - return await apiFetch({ - args: { - config, - path, - }, + return apiFetch({ + config, + path, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: communityResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/communityFilters.ts b/packages/thunderstore-api/src/get/communityFilters.ts index 5610c25b5..6bd8eb305 100644 --- a/packages/thunderstore-api/src/get/communityFilters.ts +++ b/packages/thunderstore-api/src/get/communityFilters.ts @@ -9,17 +9,15 @@ import { communityFiltersResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchCommunityFilters( +export function fetchCommunityFilters( props: ApiEndpointProps ): Promise { const { config, params } = props; const path = `api/cyberstorm/community/${params.community_id}/filters/`; - return await apiFetch({ - args: { - config, - path, - }, + return apiFetch({ + config, + path, requestSchema: undefined, queryParamsSchema: communityFiltersRequestParamsSchema, responseSchema: communityFiltersResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/communityList.ts b/packages/thunderstore-api/src/get/communityList.ts index 9405807fe..6873b5333 100644 --- a/packages/thunderstore-api/src/get/communityList.ts +++ b/packages/thunderstore-api/src/get/communityList.ts @@ -10,7 +10,7 @@ import { communityListResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchCommunityList( +export function fetchCommunityList( props: ApiEndpointProps ): Promise { const { @@ -27,12 +27,10 @@ export async function fetchCommunityList( } = props; const path = "api/cyberstorm/community/"; - return await apiFetch({ - args: { - config, - path, - queryParams, - }, + return apiFetch({ + config, + path, + queryParams, requestSchema: undefined, queryParamsSchema: communityListRequestQueryParamsSchema, responseSchema: communityListResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/communityPackageListings.ts b/packages/thunderstore-api/src/get/communityPackageListings.ts index 37ec34902..fac055f60 100644 --- a/packages/thunderstore-api/src/get/communityPackageListings.ts +++ b/packages/thunderstore-api/src/get/communityPackageListings.ts @@ -12,7 +12,7 @@ import { packageListingsResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchCommunityPackageListings( +export function fetchCommunityPackageListings( props: ApiEndpointProps< CommunityPackageListingsRequestParams, PackageListingsRequestQueryParams, @@ -37,12 +37,10 @@ export async function fetchCommunityPackageListings( { key: "deprecated", value: false, impotent: false }, ], } = props; - return await apiFetch({ - args: { - config, - path: `api/cyberstorm/listing/${params.community_id.toLowerCase()}/`, - queryParams, - }, + return apiFetch({ + config, + path: `api/cyberstorm/listing/${params.community_id.toLowerCase()}/`, + queryParams, requestSchema: communityPackageListingsRequestParamsSchema, queryParamsSchema: packageListingsRequestQueryParamsSchema, responseSchema: packageListingsResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/currentUser.ts b/packages/thunderstore-api/src/get/currentUser.ts index eed1d9c8e..812b4bba7 100644 --- a/packages/thunderstore-api/src/get/currentUser.ts +++ b/packages/thunderstore-api/src/get/currentUser.ts @@ -11,15 +11,18 @@ import { currentUserTeamPermissionsResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchCurrentUser( +export function fetchCurrentUser( props: ApiEndpointProps ): Promise { const { config } = props; const path = "api/experimental/current-user/"; const request = { cache: "no-store" as RequestCache }; - return await apiFetch({ - args: { config, path, request, useSession: true }, + return apiFetch({ + config, + path, + request, + useSession: true, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: currentUserResponseDataSchema, @@ -38,7 +41,10 @@ export async function fetchCurrentUserTeamPermissions( const request = { cache: "no-store" as RequestCache }; return await apiFetch({ - args: { config, path, request, useSession: true }, + config, + path, + request, + useSession: true, requestSchema: currentUserTeamPermissionsRequestParamsSchema, queryParamsSchema: undefined, responseSchema: currentUserTeamPermissionsResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/dynamicHTML.ts b/packages/thunderstore-api/src/get/dynamicHTML.ts index fc9d9569e..7ef009402 100644 --- a/packages/thunderstore-api/src/get/dynamicHTML.ts +++ b/packages/thunderstore-api/src/get/dynamicHTML.ts @@ -6,14 +6,16 @@ import { dynamicHTMLResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchDynamicHTML( +export function fetchDynamicHTML( props: ApiEndpointProps ): Promise { const { config, params } = props; const path = `api/cyberstorm/dynamichtml/${params.placement}`; - return await apiFetch({ - args: { config, path, request: { cache: "no-store" as RequestCache } }, + return apiFetch({ + config, + path, + request: { cache: "no-store" as RequestCache }, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: dynamicHTMLResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/namespacePackageListings.ts b/packages/thunderstore-api/src/get/namespacePackageListings.ts index e77aa3e49..e989642e0 100644 --- a/packages/thunderstore-api/src/get/namespacePackageListings.ts +++ b/packages/thunderstore-api/src/get/namespacePackageListings.ts @@ -11,7 +11,7 @@ import { packageListingsResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchNamespacePackageListings( +export function fetchNamespacePackageListings( props: ApiEndpointProps< NamespacePackageListingsRequestParams, PackageListingsRequestQueryParams, @@ -38,12 +38,10 @@ export async function fetchNamespacePackageListings( } = props; const path = `api/cyberstorm/listing/${params.community_id.toLowerCase()}/${params.namespace_id.toLowerCase()}/`; - return await apiFetch({ - args: { - config, - path, - queryParams, - }, + return apiFetch({ + config, + path, + queryParams, requestSchema: undefined, queryParamsSchema: packageListingsRequestQueryParamsSchema, responseSchema: packageListingsResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/package.ts b/packages/thunderstore-api/src/get/package.ts index 485bfc564..d54f786c2 100644 --- a/packages/thunderstore-api/src/get/package.ts +++ b/packages/thunderstore-api/src/get/package.ts @@ -6,20 +6,18 @@ import { packagePermissionsResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchPackagePermissions( +export function fetchPackagePermissions( props: ApiEndpointProps ): Promise { const { config, params } = props; const path = `api/cyberstorm/package/${params.community_id}/${params.namespace_id}/${params.package_name}/permissions`; const request = { cache: "no-store" as RequestCache }; - return await apiFetch({ - args: { - config: config, - path: path, - request: request, - useSession: true, - }, + return apiFetch({ + config: config, + path: path, + request: request, + useSession: true, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: packagePermissionsResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/packageChangelog.ts b/packages/thunderstore-api/src/get/packageChangelog.ts index 391ff57cd..5633759b2 100644 --- a/packages/thunderstore-api/src/get/packageChangelog.ts +++ b/packages/thunderstore-api/src/get/packageChangelog.ts @@ -6,7 +6,7 @@ import { packageChangelogResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchPackageChangelog( +export function fetchPackageChangelog( props: ApiEndpointProps ): Promise { const { config, params } = props; @@ -16,11 +16,9 @@ export async function fetchPackageChangelog( : `v/${params.version_number}`; const path = `api/cyberstorm/package/${params.namespace_id}/${params.package_name}/${v}/changelog/`; - return await apiFetch({ - args: { - config, - path, - }, + return apiFetch({ + config, + path, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: packageChangelogResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/packageDependantsListings.ts b/packages/thunderstore-api/src/get/packageDependantsListings.ts index 932b7553e..096c9b426 100644 --- a/packages/thunderstore-api/src/get/packageDependantsListings.ts +++ b/packages/thunderstore-api/src/get/packageDependantsListings.ts @@ -11,7 +11,7 @@ import { packageListingsResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchPackageDependantsListings( +export function fetchPackageDependantsListings( props: ApiEndpointProps< PackageDependantsListingsRequestParams, PackageListingsRequestQueryParams, @@ -38,12 +38,10 @@ export async function fetchPackageDependantsListings( } = props; const path = `api/cyberstorm/listing/${params.community_id}/${params.namespace_id}/${params.package_name}/dependants/`; - return await apiFetch({ - args: { - config, - path, - queryParams, - }, + return apiFetch({ + config, + path, + queryParams, requestSchema: undefined, queryParamsSchema: packageListingsRequestQueryParamsSchema, responseSchema: packageListingsResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/packageListingDetails.ts b/packages/thunderstore-api/src/get/packageListingDetails.ts index a9dd4a85c..682cc4559 100644 --- a/packages/thunderstore-api/src/get/packageListingDetails.ts +++ b/packages/thunderstore-api/src/get/packageListingDetails.ts @@ -4,17 +4,15 @@ import { packageListingDetailsSchema } from "../schemas/objectSchemas"; import { type PackageListingDetailsRequestParams } from "../schemas/requestSchemas"; import { type PackageListingDetailsResponseData } from "../schemas/responseSchemas"; -export async function fetchPackageListingDetails( +export function fetchPackageListingDetails( props: ApiEndpointProps ): Promise { const { config, params } = props; const path = `api/cyberstorm/listing/${params.community_id}/${params.namespace_id}/${params.package_name}/`; - return await apiFetch({ - args: { - config: config, - path: path, - }, + return apiFetch({ + config: config, + path: path, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: packageListingDetailsSchema, diff --git a/packages/thunderstore-api/src/get/packageReadme.ts b/packages/thunderstore-api/src/get/packageReadme.ts index 6657dff85..d575fb7d4 100644 --- a/packages/thunderstore-api/src/get/packageReadme.ts +++ b/packages/thunderstore-api/src/get/packageReadme.ts @@ -16,11 +16,9 @@ export async function fetchPackageReadme( : `v/${params.version_number}`; const path = `api/cyberstorm/package/${params.namespace_id}/${params.package_name}/${v}/readme/`; - return await apiFetch({ - args: { - config: config, - path: path, - }, + return apiFetch({ + config: config, + path: path, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: packageReadmeResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/packageSource.ts b/packages/thunderstore-api/src/get/packageSource.ts index 258ceea4d..eb4c83716 100644 --- a/packages/thunderstore-api/src/get/packageSource.ts +++ b/packages/thunderstore-api/src/get/packageSource.ts @@ -4,18 +4,16 @@ import { type PackageSourceRequestParams } from "../schemas/requestSchemas"; import { packageSourceResponseDataSchema } from "../schemas/responseSchemas"; import { type PackageSourceResponseData } from "../schemas/responseSchemas"; -export async function fetchPackageSource( +export function fetchPackageSource( props: ApiEndpointProps ): Promise { const { config, params } = props; const v = params.version_number ? params.version_number : "latest"; const path = `api/cyberstorm/package/${params.namespace_id}/${params.package_name}/v/${v}/source/`; - return await apiFetch({ - args: { - config: config, - path: path, - }, + return apiFetch({ + config: config, + path: path, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: packageSourceResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/packageSubmission.ts b/packages/thunderstore-api/src/get/packageSubmission.ts index a32fa4de8..e023bc0d5 100644 --- a/packages/thunderstore-api/src/get/packageSubmission.ts +++ b/packages/thunderstore-api/src/get/packageSubmission.ts @@ -14,12 +14,10 @@ export function fetchPackageSubmissionStatus( const path = `/api/experimental/submission/poll-async/${params.submission_id}`; return apiFetch({ - args: { - config: config, - path: path, - useSession: true, - request: request, - }, + config: config, + path: path, + useSession: true, + request: request, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: packageSubmissionStatusResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/packageVersionDependencies.ts b/packages/thunderstore-api/src/get/packageVersionDependencies.ts index 9d0f60365..97a45f34d 100644 --- a/packages/thunderstore-api/src/get/packageVersionDependencies.ts +++ b/packages/thunderstore-api/src/get/packageVersionDependencies.ts @@ -8,7 +8,7 @@ import { packageVersionDependenciesResponseDataSchema, } from "../index"; -export async function fetchPackageVersionDependencies( +export function fetchPackageVersionDependencies( props: ApiEndpointProps< PackageVersionDependenciesRequestParams, PackageVersionDependenciesRequestQueryParams, @@ -22,12 +22,10 @@ export async function fetchPackageVersionDependencies( } = props; const path = `api/cyberstorm/package/${params.namespace_id}/${params.package_name}/v/${params.version_number}/dependencies/`; - return await apiFetch({ - args: { - config, - path, - queryParams, - }, + return apiFetch({ + config, + path, + queryParams, requestSchema: undefined, queryParamsSchema: packageVersionDependenciesRequestQueryParamsSchema, responseSchema: packageVersionDependenciesResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/packageVersionDetails.ts b/packages/thunderstore-api/src/get/packageVersionDetails.ts index 4397343b8..4fca72a28 100644 --- a/packages/thunderstore-api/src/get/packageVersionDetails.ts +++ b/packages/thunderstore-api/src/get/packageVersionDetails.ts @@ -6,17 +6,15 @@ import { packageVersionDetailsResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchPackageVersionDetails( +export function fetchPackageVersionDetails( props: ApiEndpointProps ): Promise { const { config, params } = props; const path = `api/cyberstorm/package/${params.namespace_id}/${params.package_name}/v/${params.package_version}/`; - return await apiFetch({ - args: { - config: config, - path: path, - }, + return apiFetch({ + config: config, + path: path, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: packageVersionDetailsResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/packageVersions.ts b/packages/thunderstore-api/src/get/packageVersions.ts index f5dd15445..040e8d64a 100644 --- a/packages/thunderstore-api/src/get/packageVersions.ts +++ b/packages/thunderstore-api/src/get/packageVersions.ts @@ -4,17 +4,15 @@ import { type PackageVersionsRequestParams } from "../schemas/requestSchemas"; import { packageVersionsResponseDataSchema } from "../schemas/responseSchemas"; import { type PackageVersionsResponseData } from "../schemas/responseSchemas"; -export async function fetchPackageVersions( +export function fetchPackageVersions( props: ApiEndpointProps ): Promise { const { config, params } = props; const path = `api/cyberstorm/package/${params.namespace_id}/${params.package_name}/versions/`; - return await apiFetch({ - args: { - config: config, - path: path, - }, + return apiFetch({ + config: config, + path: path, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: packageVersionsResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/packageWiki.ts b/packages/thunderstore-api/src/get/packageWiki.ts index f15dd6c9b..8795a6c92 100644 --- a/packages/thunderstore-api/src/get/packageWiki.ts +++ b/packages/thunderstore-api/src/get/packageWiki.ts @@ -11,34 +11,30 @@ import { packageWikiResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchPackageWiki( +export function fetchPackageWiki( props: ApiEndpointProps ): Promise { const { config, params } = props; const path = `api/experimental/package/${params.namespace_id}/${params.package_name}/wiki/`; - return await apiFetch({ - args: { - config: config, - path: path, - }, + return apiFetch({ + config: config, + path: path, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: packageWikiResponseDataSchema, }); } -export async function fetchPackageWikiPage( +export function fetchPackageWikiPage( props: ApiEndpointProps ): Promise { const { config, params } = props; const path = `api/experimental/wiki/page/${params.id}/`; - return await apiFetch({ - args: { - config: config, - path: path, - }, + return apiFetch({ + config: config, + path: path, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: packageWikiPageResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/ratedPackages.ts b/packages/thunderstore-api/src/get/ratedPackages.ts index 907df690c..25aadca96 100644 --- a/packages/thunderstore-api/src/get/ratedPackages.ts +++ b/packages/thunderstore-api/src/get/ratedPackages.ts @@ -3,20 +3,18 @@ import { type ApiEndpointProps } from "../index"; import { ratedPackagesResponseDataSchema } from "../schemas/responseSchemas"; import { type RatedPackagesResponseData } from "../schemas/responseSchemas"; -export async function fetchRatedPackages( +export function fetchRatedPackages( props: ApiEndpointProps ): Promise { const { config } = props; const path = "api/experimental/current-user/rated-packages/"; const request = { cache: "no-store" as RequestCache }; - return await apiFetch({ - args: { - config: config, - path: path, - request: request, - useSession: true, - }, + return apiFetch({ + config: config, + path: path, + request: request, + useSession: true, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: ratedPackagesResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/teamDetails.ts b/packages/thunderstore-api/src/get/teamDetails.ts index 287a1db11..cd1c96e0b 100644 --- a/packages/thunderstore-api/src/get/teamDetails.ts +++ b/packages/thunderstore-api/src/get/teamDetails.ts @@ -6,17 +6,14 @@ import { teamDetailsResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchTeamDetails( +export function fetchTeamDetails( props: ApiEndpointProps ): Promise { const { config, params } = props; const path = `api/cyberstorm/team/${params.team_name}/`; - - return await apiFetch({ - args: { - config: config, - path: path, - }, + return apiFetch({ + config: config, + path: path, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: teamDetailsResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/teamMembers.ts b/packages/thunderstore-api/src/get/teamMembers.ts index 041f56d6a..6135954a6 100644 --- a/packages/thunderstore-api/src/get/teamMembers.ts +++ b/packages/thunderstore-api/src/get/teamMembers.ts @@ -6,18 +6,16 @@ import { teamMembersResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchTeamMembers( +export function fetchTeamMembers( props: ApiEndpointProps ): Promise { const { config, params } = props; const path = `api/cyberstorm/team/${params.team_name}/member/`; - return await apiFetch({ - args: { - config: config, - path: path, - useSession: true, - }, + return apiFetch({ + config: config, + path: path, + useSession: true, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: teamMembersResponseDataSchema, diff --git a/packages/thunderstore-api/src/get/teamServiceAccounts.ts b/packages/thunderstore-api/src/get/teamServiceAccounts.ts index 2bd6f46e9..87210c5cc 100644 --- a/packages/thunderstore-api/src/get/teamServiceAccounts.ts +++ b/packages/thunderstore-api/src/get/teamServiceAccounts.ts @@ -6,18 +6,16 @@ import { teamServiceAccountsResponseDataSchema, } from "../schemas/responseSchemas"; -export async function fetchTeamServiceAccounts( +export function fetchTeamServiceAccounts( props: ApiEndpointProps ): Promise { const { config, params } = props; const path = `api/cyberstorm/team/${params.team_name}/service-account/`; - return await apiFetch({ - args: { - config, - path, - useSession: true, - }, + return apiFetch({ + config: config, + path: path, + useSession: true, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: teamServiceAccountsResponseDataSchema, diff --git a/packages/thunderstore-api/src/patch/teamDetailsEdit.ts b/packages/thunderstore-api/src/patch/teamDetailsEdit.ts index ad349a56c..e1835ab80 100644 --- a/packages/thunderstore-api/src/patch/teamDetailsEdit.ts +++ b/packages/thunderstore-api/src/patch/teamDetailsEdit.ts @@ -27,15 +27,13 @@ export function teamDetailsEdit( const path = `api/cyberstorm/team/${params.teamIdentifier}/update/`; return apiFetch({ - args: { - config, - path, - request: { - method: "PATCH", - body: JSON.stringify(data), - }, - useSession: true, + config, + path, + request: { + method: "PATCH", + body: JSON.stringify(data), }, + useSession: true, requestSchema: teamDetailsEditRequestDataSchema, queryParamsSchema: undefined, responseSchema: teamDetailsEditResponseSchema, diff --git a/packages/thunderstore-api/src/patch/teamEditMember.ts b/packages/thunderstore-api/src/patch/teamEditMember.ts index 16317aaaf..c92d019d8 100644 --- a/packages/thunderstore-api/src/patch/teamEditMember.ts +++ b/packages/thunderstore-api/src/patch/teamEditMember.ts @@ -27,15 +27,13 @@ export function teamEditMember( const path = `/api/cyberstorm/team/${params.teamIdentifier}/member/${params.username}/update/`; return apiFetch({ - args: { - config, - path, - request: { - method: "PATCH", - body: JSON.stringify(data), - }, - useSession: true, + config, + path, + request: { + method: "PATCH", + body: JSON.stringify(data), }, + useSession: true, requestSchema: teamMemberEditRequestParamsSchema, queryParamsSchema: undefined, responseSchema: teamEditMemberResponseSchema, diff --git a/packages/thunderstore-api/src/post/frontend.ts b/packages/thunderstore-api/src/post/frontend.ts index 5e3424ff7..ecbbcad8a 100644 --- a/packages/thunderstore-api/src/post/frontend.ts +++ b/packages/thunderstore-api/src/post/frontend.ts @@ -20,13 +20,11 @@ export function toolsMarkdownPreview( const path = `/api/experimental/frontend/render-markdown/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - body: JSON.stringify(data), - }, + config, + path, + request: { + method: "POST", + body: JSON.stringify(data), }, requestSchema: markdownRenderRequestDataSchema, queryParamsSchema: undefined, diff --git a/packages/thunderstore-api/src/post/package.ts b/packages/thunderstore-api/src/post/package.ts index a081b1607..0ee4a7269 100644 --- a/packages/thunderstore-api/src/post/package.ts +++ b/packages/thunderstore-api/src/post/package.ts @@ -31,16 +31,14 @@ export function packageRate( const path = `/api/cyberstorm/package/${params.namespace}/${params.package}/rate/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - cache: "no-store", - body: JSON.stringify(data), - }, - useSession: props.useSession, + config, + path, + request: { + method: "POST", + cache: "no-store", + body: JSON.stringify(data), }, + useSession: props.useSession, requestSchema: packageRateRequestDataSchema, queryParamsSchema: undefined, responseSchema: packageRateResponseDataSchema, @@ -58,16 +56,14 @@ export function packageDeprecate( const path = `/api/cyberstorm/package/${params.namespace}/${params.package}/deprecate/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - cache: "no-store", - body: JSON.stringify(data), - }, - useSession: props.useSession, + config, + path, + request: { + method: "POST", + cache: "no-store", + body: JSON.stringify(data), }, + useSession: props.useSession, requestSchema: packageDeprecateRequestDataSchema, queryParamsSchema: undefined, responseSchema: packageDeprecateResponseDataSchema, @@ -85,16 +81,14 @@ export function packageUnlist( const path = `/c/${params.community}/${params.namespace}/${params.package}/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - cache: "no-store", - body: JSON.stringify(data), - }, - useSession: props.useSession, + config, + path, + request: { + method: "POST", + cache: "no-store", + body: JSON.stringify(data), }, + useSession: props.useSession, requestSchema: packageUnlistRequestDataSchema, queryParamsSchema: undefined, responseSchema: packageUnlistResponseDataSchema, diff --git a/packages/thunderstore-api/src/post/packageListing.ts b/packages/thunderstore-api/src/post/packageListing.ts index c1e842b58..c6a584754 100644 --- a/packages/thunderstore-api/src/post/packageListing.ts +++ b/packages/thunderstore-api/src/post/packageListing.ts @@ -30,16 +30,14 @@ export function packageListingUpdate( const path = `/api/cyberstorm/listing/${params.community}/${params.namespace}/${params.package}/update/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - cache: "no-store", - body: JSON.stringify(data), - }, - useSession: true, + config, + path, + request: { + method: "POST", + cache: "no-store", + body: JSON.stringify(data), }, + useSession: true, requestSchema: packageListingUpdateRequestDataSchema, queryParamsSchema: undefined, responseSchema: packageListingUpdateResponseDataSchema, @@ -57,16 +55,14 @@ export function packageListingApprove( const path = `/api/cyberstorm/listing/${params.community}/${params.namespace}/${params.package}/approve/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - cache: "no-store", - body: JSON.stringify(data), - }, - useSession: true, + config, + path, + request: { + method: "POST", + cache: "no-store", + body: JSON.stringify(data), }, + useSession: true, requestSchema: packageListingApproveRequestDataSchema, queryParamsSchema: undefined, responseSchema: undefined, @@ -84,16 +80,14 @@ export function packageListingReject( const path = `/api/cyberstorm/listing/${params.community}/${params.namespace}/${params.package}/reject/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - cache: "no-store", - body: JSON.stringify(data), - }, - useSession: true, + config, + path, + request: { + method: "POST", + cache: "no-store", + body: JSON.stringify(data), }, + useSession: true, requestSchema: packageListingRejectRequestDataSchema, queryParamsSchema: undefined, responseSchema: undefined, @@ -110,16 +104,14 @@ export function packageListingReport( const { config, params, data } = props; const path = `/api/cyberstorm/listing/${params.community}/${params.namespace}/${params.package}/report/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - cache: "no-store", - body: JSON.stringify(data), - }, - useSession: true, + config, + path, + request: { + method: "POST", + cache: "no-store", + body: JSON.stringify(data), }, + useSession: true, requestSchema: packageListingReportRequestDataSchema, queryParamsSchema: undefined, responseSchema: undefined, diff --git a/packages/thunderstore-api/src/post/packageWiki.ts b/packages/thunderstore-api/src/post/packageWiki.ts index 437c5d418..9c21dbde8 100644 --- a/packages/thunderstore-api/src/post/packageWiki.ts +++ b/packages/thunderstore-api/src/post/packageWiki.ts @@ -15,7 +15,7 @@ import { packageWikiPageEditResponseDataSchema, } from "../schemas/responseSchemas"; -export async function postPackageWikiPageCreate( +export function postPackageWikiPageCreate( props: ApiEndpointProps< PackageWikiPageCreateRequestParams, object, @@ -25,15 +25,13 @@ export async function postPackageWikiPageCreate( const { config, params, data } = props; const path = `api/experimental/package/${params.namespace_id}/${params.package_name}/wiki/`; - return await apiFetch({ - args: { - config: config, - path: path, - request: { - method: "POST", - cache: "no-store", - body: JSON.stringify(data), - }, + return apiFetch({ + config: config, + path: path, + request: { + method: "POST", + cache: "no-store", + body: JSON.stringify(data), }, requestSchema: packageWikiPageCreateRequestDataSchema, queryParamsSchema: undefined, @@ -41,7 +39,7 @@ export async function postPackageWikiPageCreate( }); } -export async function postPackageWikiPageEdit( +export function postPackageWikiPageEdit( props: ApiEndpointProps< PackageWikiPageEditRequestParams, object, @@ -51,15 +49,13 @@ export async function postPackageWikiPageEdit( const { config, params, data } = props; const path = `api/experimental/package/${params.namespace_id}/${params.package_name}/wiki/`; - return await apiFetch({ - args: { - config: config, - path: path, - request: { - method: "POST", - cache: "no-store", - body: JSON.stringify(data), - }, + return apiFetch({ + config: config, + path: path, + request: { + method: "POST", + cache: "no-store", + body: JSON.stringify(data), }, requestSchema: packageWikiPageEditRequestDataSchema, queryParamsSchema: undefined, diff --git a/packages/thunderstore-api/src/post/submission.ts b/packages/thunderstore-api/src/post/submission.ts index ba96a72d1..5e6b41546 100644 --- a/packages/thunderstore-api/src/post/submission.ts +++ b/packages/thunderstore-api/src/post/submission.ts @@ -20,17 +20,15 @@ export function postPackageSubmission( const path = `/api/experimental/submission/submit-async/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - cache: "no-store", - body: JSON.stringify(data), - }, - bodyRaw: data, - useSession: true, + config, + path, + request: { + method: "POST", + cache: "no-store", + body: JSON.stringify(data), }, + bodyRaw: data, + useSession: true, requestSchema: packageSubmissionRequestDataSchema, queryParamsSchema: undefined, responseSchema: packageSubmissionResponseDataSchema, @@ -44,15 +42,13 @@ export function toolsManifestValidate( const path = `/api/experimental/submission/validate/manifest-v1/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - body: JSON.stringify(data), - }, - useSession: true, + config, + path, + request: { + method: "POST", + body: JSON.stringify(data), }, + useSession: true, requestSchema: submissionValidateManifestRequestDataSchema, queryParamsSchema: undefined, responseSchema: submissionValidateManifestResponseDataSchema, diff --git a/packages/thunderstore-api/src/post/team.ts b/packages/thunderstore-api/src/post/team.ts index b0d90a1e5..9afe6a4a6 100644 --- a/packages/thunderstore-api/src/post/team.ts +++ b/packages/thunderstore-api/src/post/team.ts @@ -16,15 +16,13 @@ export function teamCreate( const path = "api/cyberstorm/team/create/"; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - body: JSON.stringify(data), - }, - useSession: true, + config, + path, + request: { + method: "POST", + body: JSON.stringify(data), }, + useSession: true, requestSchema: teamCreateRequestDataSchema, queryParamsSchema: undefined, responseSchema: teamCreateResponseDataSchema, diff --git a/packages/thunderstore-api/src/post/teamAddServiceAccount.ts b/packages/thunderstore-api/src/post/teamAddServiceAccount.ts index 6a958bb66..b7ed97d4b 100644 --- a/packages/thunderstore-api/src/post/teamAddServiceAccount.ts +++ b/packages/thunderstore-api/src/post/teamAddServiceAccount.ts @@ -28,15 +28,13 @@ export function teamAddServiceAccount( const path = `api/cyberstorm/team/${params.team_name}/service-account/create/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - body: JSON.stringify(data), - }, - useSession: true, + config, + path, + request: { + method: "POST", + body: JSON.stringify(data), }, + useSession: true, requestSchema: teamServiceAccountAddRequestDataSchema, queryParamsSchema: undefined, responseSchema: teamServiceAccountAddResponseSchema, diff --git a/packages/thunderstore-api/src/post/teamMember.ts b/packages/thunderstore-api/src/post/teamMember.ts index 619f71550..286abfafa 100644 --- a/packages/thunderstore-api/src/post/teamMember.ts +++ b/packages/thunderstore-api/src/post/teamMember.ts @@ -21,15 +21,13 @@ export function teamAddMember( const path = `/api/cyberstorm/team/${params.team_name}/member/add/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - body: JSON.stringify(data), - }, - useSession: true, + config, + path, + request: { + method: "POST", + body: JSON.stringify(data), }, + useSession: true, requestSchema: teamAddMemberRequestDataSchema, queryParamsSchema: undefined, responseSchema: teamAddMemberResponseDataSchema, diff --git a/packages/thunderstore-api/src/post/usermedia.ts b/packages/thunderstore-api/src/post/usermedia.ts index 9ba54fe7f..72acea84b 100644 --- a/packages/thunderstore-api/src/post/usermedia.ts +++ b/packages/thunderstore-api/src/post/usermedia.ts @@ -24,16 +24,14 @@ export function postUsermediaInitiate( const path = `/api/experimental/usermedia/initiate-upload/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - cache: "no-store", - body: JSON.stringify(data), - }, - useSession, + config, + path, + request: { + method: "POST", + cache: "no-store", + body: JSON.stringify(data), }, + useSession, requestSchema: usermediaInitiateUploadRequestDataSchema, queryParamsSchema: undefined, responseSchema: usermediaInitiateUploadResponseDataSchema, @@ -47,15 +45,13 @@ export function postUsermediaAbort( const path = `/api/experimental/usermedia/${params.uuid}/abort-upload/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - cache: "no-store", - }, - useSession, + config, + path, + request: { + method: "POST", + cache: "no-store", }, + useSession, requestSchema: undefined, queryParamsSchema: undefined, responseSchema: usermediaAbortUploadResponseDataSchema, @@ -73,16 +69,14 @@ export function postUsermediaFinish( const path = `/api/experimental/usermedia/${params.uuid}/finish-upload/`; return apiFetch({ - args: { - config, - path, - request: { - method: "POST", - cache: "no-store", - body: JSON.stringify(data), - }, - useSession, + config, + path, + request: { + method: "POST", + cache: "no-store", + body: JSON.stringify(data), }, + useSession, requestSchema: usermediaFinishUploadRequestDataSchema, queryParamsSchema: undefined, responseSchema: usermediaFinishUploadResponseDataSchema,