Merged changes from o10aupva/main
Replit-Task-Id: 96838fc6-bf00-4a8d-ae18-84ba08feec56
This commit is contained in:
@@ -1,10 +1,38 @@
|
||||
/**
|
||||
* Generated by orval v8.5.3 🍺
|
||||
* Generated by orval v8.9.1 🍺
|
||||
* Do not edit manually.
|
||||
* Api
|
||||
* API specification
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
export interface ContactRequest {
|
||||
/**
|
||||
* @minLength 1
|
||||
* @maxLength 100
|
||||
*/
|
||||
name: string;
|
||||
/** @maxLength 200 */
|
||||
email: string;
|
||||
/** @maxLength 200 */
|
||||
subject?: string;
|
||||
/**
|
||||
* @minLength 1
|
||||
* @maxLength 5000
|
||||
*/
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface ContactResponse {
|
||||
success: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface ContactError {
|
||||
success: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface HealthStatus {
|
||||
status: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,101 +1,190 @@
|
||||
/**
|
||||
* Generated by orval v8.5.3 🍺
|
||||
* Generated by orval v8.9.1 🍺
|
||||
* Do not edit manually.
|
||||
* Api
|
||||
* API specification
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
useMutation,
|
||||
useQuery
|
||||
} from '@tanstack/react-query';
|
||||
import type {
|
||||
MutationFunction,
|
||||
QueryFunction,
|
||||
QueryKey,
|
||||
UseMutationOptions,
|
||||
UseMutationResult,
|
||||
UseQueryOptions,
|
||||
UseQueryResult,
|
||||
} from "@tanstack/react-query";
|
||||
UseQueryResult
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
import type { HealthStatus } from "./api.schemas";
|
||||
import type {
|
||||
ContactError,
|
||||
ContactRequest,
|
||||
ContactResponse,
|
||||
HealthStatus
|
||||
} from './api.schemas';
|
||||
|
||||
import { customFetch } from "../custom-fetch";
|
||||
import type { ErrorType } from "../custom-fetch";
|
||||
import { customFetch } from '../custom-fetch';
|
||||
import type { ErrorType , BodyType } from '../custom-fetch';
|
||||
|
||||
type AwaitedInput<T> = PromiseLike<T> | T;
|
||||
|
||||
type Awaited<O> = O extends AwaitedInput<infer T> ? T : never;
|
||||
type Awaited<O> = O extends AwaitedInput<infer T> ? T : never;
|
||||
|
||||
|
||||
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
||||
|
||||
|
||||
|
||||
export const getSendContactMessageUrl = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
return `/api/contact`
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a contact message via email
|
||||
* @summary Send contact form message
|
||||
*/
|
||||
export const sendContactMessage = async (contactRequest: ContactRequest, options?: RequestInit): Promise<ContactResponse> => {
|
||||
|
||||
return customFetch<ContactResponse>(getSendContactMessageUrl(),
|
||||
{
|
||||
...options,
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
||||
body: JSON.stringify(
|
||||
contactRequest,)
|
||||
}
|
||||
);}
|
||||
|
||||
|
||||
|
||||
|
||||
export const getSendContactMessageMutationOptions = <TError = ErrorType<ContactError>,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof sendContactMessage>>, TError,{data: BodyType<ContactRequest>}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof sendContactMessage>>, TError,{data: BodyType<ContactRequest>}, TContext> => {
|
||||
|
||||
const mutationKey = ['sendContactMessage'];
|
||||
const {mutation: mutationOptions, request: requestOptions} = options ?
|
||||
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
||||
options
|
||||
: {...options, mutation: {...options.mutation, mutationKey}}
|
||||
: {mutation: { mutationKey, }, request: undefined};
|
||||
|
||||
|
||||
|
||||
|
||||
const mutationFn: MutationFunction<Awaited<ReturnType<typeof sendContactMessage>>, {data: BodyType<ContactRequest>}> = (props) => {
|
||||
const {data} = props ?? {};
|
||||
|
||||
return sendContactMessage(data,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type SendContactMessageMutationResult = NonNullable<Awaited<ReturnType<typeof sendContactMessage>>>
|
||||
export type SendContactMessageMutationBody = BodyType<ContactRequest>
|
||||
export type SendContactMessageMutationError = ErrorType<ContactError>
|
||||
|
||||
/**
|
||||
* @summary Send contact form message
|
||||
*/
|
||||
export const useSendContactMessage = <TError = ErrorType<ContactError>,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof sendContactMessage>>, TError,{data: BodyType<ContactRequest>}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof sendContactMessage>>,
|
||||
TError,
|
||||
{data: BodyType<ContactRequest>},
|
||||
TContext
|
||||
> => {
|
||||
return useMutation(getSendContactMessageMutationOptions(options));
|
||||
}
|
||||
|
||||
export const getHealthCheckUrl = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
return `/api/healthz`
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns server health status
|
||||
* @summary Health check
|
||||
*/
|
||||
export const getHealthCheckUrl = () => {
|
||||
return `/api/healthz`;
|
||||
};
|
||||
export const healthCheck = async ( options?: RequestInit): Promise<HealthStatus> => {
|
||||
|
||||
export const healthCheck = async (
|
||||
options?: RequestInit,
|
||||
): Promise<HealthStatus> => {
|
||||
return customFetch<HealthStatus>(getHealthCheckUrl(), {
|
||||
return customFetch<HealthStatus>(getHealthCheckUrl(),
|
||||
{
|
||||
...options,
|
||||
method: "GET",
|
||||
});
|
||||
};
|
||||
method: 'GET'
|
||||
|
||||
|
||||
}
|
||||
);}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const getHealthCheckQueryKey = () => {
|
||||
return [`/api/healthz`] as const;
|
||||
};
|
||||
return [
|
||||
`/api/healthz`
|
||||
] as const;
|
||||
}
|
||||
|
||||
export const getHealthCheckQueryOptions = <
|
||||
TData = Awaited<ReturnType<typeof healthCheck>>,
|
||||
TError = ErrorType<unknown>,
|
||||
>(options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof healthCheck>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
request?: SecondParameter<typeof customFetch>;
|
||||
}) => {
|
||||
const { query: queryOptions, request: requestOptions } = options ?? {};
|
||||
|
||||
const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey();
|
||||
export const getHealthCheckQueryOptions = <TData = Awaited<ReturnType<typeof healthCheck>>, TError = ErrorType<unknown>>( options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof healthCheck>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
|
||||
) => {
|
||||
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof healthCheck>>> = ({
|
||||
signal,
|
||||
}) => healthCheck({ signal, ...requestOptions });
|
||||
const {query: queryOptions, request: requestOptions} = options ?? {};
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof healthCheck>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: QueryKey };
|
||||
};
|
||||
const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey();
|
||||
|
||||
|
||||
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof healthCheck>>> = ({ signal }) => healthCheck({ signal, ...requestOptions });
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof healthCheck>>, TError, TData> & { queryKey: QueryKey }
|
||||
}
|
||||
|
||||
export type HealthCheckQueryResult = NonNullable<Awaited<ReturnType<typeof healthCheck>>>
|
||||
export type HealthCheckQueryError = ErrorType<unknown>
|
||||
|
||||
export type HealthCheckQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof healthCheck>>
|
||||
>;
|
||||
export type HealthCheckQueryError = ErrorType<unknown>;
|
||||
|
||||
/**
|
||||
* @summary Health check
|
||||
*/
|
||||
|
||||
export function useHealthCheck<
|
||||
TData = Awaited<ReturnType<typeof healthCheck>>,
|
||||
TError = ErrorType<unknown>,
|
||||
>(options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof healthCheck>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
request?: SecondParameter<typeof customFetch>;
|
||||
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
||||
const queryOptions = getHealthCheckQueryOptions(options);
|
||||
export function useHealthCheck<TData = Awaited<ReturnType<typeof healthCheck>>, TError = ErrorType<unknown>>(
|
||||
options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof healthCheck>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
|
||||
|
||||
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
||||
queryKey: QueryKey;
|
||||
};
|
||||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
||||
|
||||
const queryOptions = getHealthCheckQueryOptions(options)
|
||||
|
||||
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
||||
|
||||
return { ...query, queryKey: queryOptions.queryKey };
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,40 @@ servers:
|
||||
tags:
|
||||
- name: health
|
||||
description: Health operations
|
||||
- name: contact
|
||||
description: Contact form
|
||||
paths:
|
||||
/contact:
|
||||
post:
|
||||
operationId: sendContactMessage
|
||||
tags: [contact]
|
||||
summary: Send contact form message
|
||||
description: Sends a contact message via email
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ContactRequest"
|
||||
responses:
|
||||
"200":
|
||||
description: Message sent successfully
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ContactResponse"
|
||||
"400":
|
||||
description: Validation error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ContactError"
|
||||
"500":
|
||||
description: Server error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ContactError"
|
||||
/healthz:
|
||||
get:
|
||||
operationId: healthCheck
|
||||
@@ -26,6 +59,48 @@ paths:
|
||||
$ref: "#/components/schemas/HealthStatus"
|
||||
components:
|
||||
schemas:
|
||||
ContactRequest:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 100
|
||||
email:
|
||||
type: string
|
||||
format: email
|
||||
maxLength: 200
|
||||
subject:
|
||||
type: string
|
||||
maxLength: 200
|
||||
message:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 5000
|
||||
required:
|
||||
- name
|
||||
- email
|
||||
- message
|
||||
ContactResponse:
|
||||
type: object
|
||||
properties:
|
||||
success:
|
||||
type: boolean
|
||||
message:
|
||||
type: string
|
||||
required:
|
||||
- success
|
||||
- message
|
||||
ContactError:
|
||||
type: object
|
||||
properties:
|
||||
success:
|
||||
type: boolean
|
||||
message:
|
||||
type: string
|
||||
required:
|
||||
- success
|
||||
- message
|
||||
HealthStatus:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
@@ -1,16 +1,46 @@
|
||||
/**
|
||||
* Generated by orval v8.5.3 🍺
|
||||
* Generated by orval v8.9.1 🍺
|
||||
* Do not edit manually.
|
||||
* Api
|
||||
* API specification
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import * as zod from "zod";
|
||||
import * as zod from 'zod';
|
||||
|
||||
|
||||
/**
|
||||
* Sends a contact message via email
|
||||
* @summary Send contact form message
|
||||
*/
|
||||
export const sendContactMessageBodyNameMax = 100;
|
||||
|
||||
export const sendContactMessageBodyEmailMax = 200;
|
||||
|
||||
export const sendContactMessageBodySubjectMax = 200;
|
||||
|
||||
export const sendContactMessageBodyMessageMax = 5000;
|
||||
|
||||
|
||||
|
||||
export const SendContactMessageBody = zod.object({
|
||||
"name": zod.string().min(1).max(sendContactMessageBodyNameMax),
|
||||
"email": zod.string().email().max(sendContactMessageBodyEmailMax),
|
||||
"subject": zod.string().max(sendContactMessageBodySubjectMax).optional(),
|
||||
"message": zod.string().min(1).max(sendContactMessageBodyMessageMax)
|
||||
})
|
||||
|
||||
export const SendContactMessageResponse = zod.object({
|
||||
"success": zod.boolean(),
|
||||
"message": zod.string()
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* Returns server health status
|
||||
* @summary Health check
|
||||
*/
|
||||
export const HealthCheckResponse = zod.object({
|
||||
status: zod.string(),
|
||||
});
|
||||
"status": zod.string()
|
||||
})
|
||||
|
||||
|
||||
|
||||
12
lib/api-zod/src/generated/types/contactError.ts
Normal file
12
lib/api-zod/src/generated/types/contactError.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Generated by orval v8.9.1 🍺
|
||||
* Do not edit manually.
|
||||
* Api
|
||||
* API specification
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export interface ContactError {
|
||||
success: boolean;
|
||||
message: string;
|
||||
}
|
||||
24
lib/api-zod/src/generated/types/contactRequest.ts
Normal file
24
lib/api-zod/src/generated/types/contactRequest.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Generated by orval v8.9.1 🍺
|
||||
* Do not edit manually.
|
||||
* Api
|
||||
* API specification
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export interface ContactRequest {
|
||||
/**
|
||||
* @minLength 1
|
||||
* @maxLength 100
|
||||
*/
|
||||
name: string;
|
||||
/** @maxLength 200 */
|
||||
email: string;
|
||||
/** @maxLength 200 */
|
||||
subject?: string;
|
||||
/**
|
||||
* @minLength 1
|
||||
* @maxLength 5000
|
||||
*/
|
||||
message: string;
|
||||
}
|
||||
12
lib/api-zod/src/generated/types/contactResponse.ts
Normal file
12
lib/api-zod/src/generated/types/contactResponse.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Generated by orval v8.9.1 🍺
|
||||
* Do not edit manually.
|
||||
* Api
|
||||
* API specification
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export interface ContactResponse {
|
||||
success: boolean;
|
||||
message: string;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Generated by orval v8.5.3 🍺
|
||||
* Generated by orval v8.9.1 🍺
|
||||
* Do not edit manually.
|
||||
* Api
|
||||
* API specification
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
/**
|
||||
* Generated by orval v8.5.3 🍺
|
||||
* Generated by orval v8.9.1 🍺
|
||||
* Do not edit manually.
|
||||
* Api
|
||||
* API specification
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export * from "./healthStatus";
|
||||
export * from './contactError';
|
||||
export * from './contactRequest';
|
||||
export * from './contactResponse';
|
||||
export * from './healthStatus';
|
||||
|
||||
Reference in New Issue
Block a user