Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
945 changes: 559 additions & 386 deletions src/package-lock.json.jinja

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/package.json.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"devDependencies": {
"@eslint/config-helpers": "~0.5",
"@eslint/js": "~9.39",
"@hey-api/openapi-ts": "~0.92",
"@hey-api/openapi-ts": "~0.93",
"@lingui/cli": "~5.9",
"@lingui/format-po": "~5.9",
"@lingui/loader": "~5.9",
Expand Down
5 changes: 4 additions & 1 deletion src/src/common/apis/icanhazdadjoke/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export interface RequestOptions<
}>,
Pick<
ServerSentEventsOptions<TData>,
| "onRequest"
| "onSseError"
| "onSseEvent"
| "sseDefaultRetryDelay"
Expand Down Expand Up @@ -214,7 +215,9 @@ export type Client = CoreClient<
*/
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
override?: Config<ClientOptions & T>,
) => Config<Required<ClientOptions> & T>;
) =>
| Config<Required<ClientOptions> & T>
| Promise<Config<Required<ClientOptions> & T>>;

export interface TDataShape {
body?: unknown;
Expand Down
4 changes: 3 additions & 1 deletion src/src/common/apis/icanhazdadjoke/clnt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import type { ClientOptions as ClientOptions2 } from "./types";
*/
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (
override?: Config<ClientOptions & T>,
) => Config<Required<ClientOptions> & T>;
) =>
| Config<Required<ClientOptions> & T>
| Promise<Config<Required<ClientOptions> & T>>;

export const client = createClient(createConfig<ClientOptions2>());
7 changes: 6 additions & 1 deletion src/src/common/apis/icanhazdadjoke/core/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ interface Params {

const stripEmptySlots = (params: Params) => {
for (const [slot, value] of Object.entries(params)) {
if (value && typeof value === "object" && !Object.keys(value).length) {
if (
value &&
typeof value === "object" &&
!Array.isArray(value) &&
!Object.keys(value).length
) {
delete params[slot as Slot];
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/src/common/apis/icanhazdadjoke/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export const GetRandomJokeSuccessResponsePayloadSchema = z
});

export const GetRandomJokeRequestSchema = z.object({
body: z.optional(z.never()),
path: z.optional(z.never()),
query: z.optional(z.never()),
body: z.never().optional(),
path: z.never().optional(),
query: z.never().optional(),
});

/**
Expand Down
4 changes: 3 additions & 1 deletion src/src/isomorphic/core/hooks/use-form/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ export function useForm<SchemaType extends ZodObject>({

const handleSubmit = useCallback(
async (values: UseFormValues<SchemaType>) => {
if (!onSubmit) return;

setSubmitting(true);

try {
const result = await onSubmit?.({ values: values });
const result = await onSubmit({ values: values });
handleSubmitResult(
result,
form.reset,
Expand Down
22 changes: 12 additions & 10 deletions src/src/isomorphic/core/hooks/use-form/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MessageDescriptor } from "@lingui/core";
import type { UseFormReturnType as UseMantineFormReturnType } from "@mantine/form";
import type { FormEvent } from "react";
import type { SubmitEvent } from "react";
import type { Paths } from "type-fest";
import type * as z from "zod";

Expand All @@ -9,9 +9,7 @@ export type ZodObject = z.core.$ZodObject;
export type UseFormValues<SchemaType extends ZodObject> = z.infer<SchemaType>;

export type UseFormErrors<SchemaType extends ZodObject> = {
[path in Paths<UseFormValues<SchemaType>, { leavesOnly: true }>]?:
| MessageDescriptor
| string;
[path in Paths<UseFormValues<SchemaType>>]?: MessageDescriptor | string;
};

export type UseFormSubmitErrorOutput<SchemaType extends ZodObject> = {
Expand All @@ -25,8 +23,10 @@ export type UseFormSubmitSuccessOutput<SchemaType extends ZodObject> = void | {
};

export type UseFormSubmitOutput<SchemaType extends ZodObject> =
| undefined
| UseFormSubmitErrorOutput<SchemaType>
| UseFormSubmitSuccessOutput<SchemaType>;
| UseFormSubmitSuccessOutput<SchemaType>
| void;

export type UseFormInitialValues<SchemaType extends ZodObject> =
UseFormValues<SchemaType>;
Expand All @@ -37,17 +37,19 @@ export type UseFormSubmitInput<SchemaType extends ZodObject> = {
values: UseFormValues<SchemaType>;
};

export type UseFormOnSubmit<SchemaType extends ZodObject> = (
input: UseFormSubmitInput<SchemaType>,
) => Promise<UseFormSubmitOutput<SchemaType>>;
export type UseFormOnSubmit<SchemaType extends ZodObject> =
| ((
input: UseFormSubmitInput<SchemaType>,
) => Promise<UseFormSubmitOutput<SchemaType>>)
| undefined;

export type UseFormSchema<SchemaType extends ZodObject> = SchemaType;

export type UseFormForm<SchemaType extends ZodObject> =
UseMantineFormReturnType<UseFormValues<SchemaType>>;

export type UseFormHandleFormSubmitEvent =
| FormEvent<HTMLFormElement>
| SubmitEvent<HTMLFormElement>
| undefined;

export type UseFormHandleFormSubmit = (
Expand All @@ -59,7 +61,7 @@ export type UseFormSubmitting = boolean;
export type UseFormInput<SchemaType extends ZodObject> = {
initialValues: UseFormInitialValues<SchemaType>;
onError?: UseFormOnError;
onSubmit: UseFormOnSubmit<SchemaType>;
onSubmit?: UseFormOnSubmit<SchemaType>;
schema: UseFormSchema<SchemaType>;
};

Expand Down