Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Migrate to tRPC v11 #472

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
30 changes: 16 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@
"@react-email/render": "0.0.16",
"@stoplight/elements": "8.3.3",
"@t3-oss/env-nextjs": "0.7.3",
"@tanstack/react-query": "4.36.1",
"@tanstack/react-query-devtools": "4.36.1",
"@trpc/client": "10.45.2",
"@trpc/react-query": "10.45.2",
"@trpc/server": "10.45.2",
"@tanstack/react-query": "5.62.2",
"@tanstack/react-query-devtools": "5.62.2",
"@trpc/client": "11.0.0-rc.648",
"@trpc/next": "11.0.0-rc.648",
"@trpc/react-query": "11.0.0-rc.648",
"@trpc/server": "11.0.0-rc.648",
"arctic": "1.9.2",
"bcrypt": "5.1.1",
"chakra-react-select": "4.9.1",
Expand Down Expand Up @@ -97,10 +98,11 @@
"sharp": "0.33.4",
"sonner": "1.5.0",
"superjson": "2.2.1",
"trpc-openapi": "1.2.0",
"ts-pattern": "5.2.0",
"trpc-to-openapi": "2.1.0",
"ts-pattern": "5.6.0",
"zod": "3.23.8",
"zod-i18n-map": "2.27.0",
"zod-openapi": "4.2.1",
"zustand": "4.5.4"
},
"devDependencies": {
Expand All @@ -110,12 +112,12 @@
"@chakra-ui/cli": "2.4.1",
"@next/eslint-plugin-next": "14.2.4",
"@playwright/test": "1.45.1",
"@storybook/addon-actions": "8.1.11",
"@storybook/addon-essentials": "8.1.11",
"@storybook/addon-links": "8.1.11",
"@storybook/nextjs": "8.1.11",
"@storybook/react": "8.1.11",
"@storybook/theming": "8.1.11",
"@storybook/addon-actions": "8.4.7",
"@storybook/addon-essentials": "8.4.7",
"@storybook/addon-links": "8.4.7",
"@storybook/nextjs": "8.4.7",
"@storybook/react": "8.4.7",
"@storybook/theming": "8.4.7",
"@svgr/cli": "8.1.0",
"@testing-library/dom": "10.3.1",
"@testing-library/react": "16.0.0",
Expand Down Expand Up @@ -146,7 +148,7 @@
"npm-run-all": "4.1.5",
"prettier": "3.3.2",
"prisma": "5.16.2",
"storybook": "8.1.11",
"storybook": "8.4.7",
"storybook-dark-mode": "4.0.2",
"tsx": "4.16.2",
"typescript": "5.5.3",
Expand Down
9,939 changes: 3,738 additions & 6,201 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/app/api/rest/[...path]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createOpenApiFetchHandler } from 'trpc-to-openapi';

import { createTRPCContext } from '@/server/config/trpc';
import { createOpenApiFetchHandler } from '@/server/config/trpc-open-api';
import { appRouter } from '@/server/router';

const handler = (req: Request) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const AccountDeleteVerificationCodeModale = () => {
<Form {...form} onSubmit={onSubmit}>
<VerificationCodeForm
email={searchParams[SEARCH_PARAM_VERIFY_EMAIL] ?? ''}
isLoading={updateEmailValidate.isLoading}
isLoading={updateEmailValidate.isPending}
confirmText={t('account:deleteAccount.validate.button')}
confirmVariant="@dangerPrimary"
autoSubmit={false}
Expand Down
4 changes: 2 additions & 2 deletions src/features/account/AccountEmailForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const AccountEmailForm = () => {

return (
<>
{account.isLoading && <LoaderFull />}
{account.isPending && <LoaderFull />}
{account.isError && <ErrorPage />}
{account.isSuccess && (
<Stack spacing={4}>
Expand All @@ -83,7 +83,7 @@ export const AccountEmailForm = () => {
type="submit"
variant="@primary"
isDisabled={account.data.email === email}
isLoading={updateEmail.isLoading}
isLoading={updateEmail.isPending}
>
{t('account:email.actions.update')}
</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/features/account/AccountProfileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const AccountProfileForm = () => {

return (
<>
{account.isLoading && <LoaderFull />}
{account.isPending && <LoaderFull />}
{account.isError && <ErrorPage />}
{account.isSuccess && (
<Stack spacing={4}>
Expand Down Expand Up @@ -95,7 +95,7 @@ export const AccountProfileForm = () => {
<Button
type="submit"
variant="@primary"
isLoading={updateAccount.isLoading}
isLoading={updateAccount.isPending}
>
{t('account:profile.actions.update')}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/features/account/EmailVerificationCodeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const EmailVerificationCodeModale = () => {
<VerificationCodeForm
email={searchParams.verifyEmail ?? ''}
isLoading={
updateEmailValidate.isLoading || updateEmailValidate.isSuccess
updateEmailValidate.isPending || updateEmailValidate.isSuccess
}
/>
</Form>
Expand Down
2 changes: 1 addition & 1 deletion src/features/app/AppNavBarDesktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const AppNavBarDesktop = (props: BoxProps) => {
}
: {})}
>
{account.isLoading && <Spinner size="xs" />}
{account.isPending && <Spinner size="xs" />}
</Avatar>
</HStack>
</Container>
Expand Down
2 changes: 1 addition & 1 deletion src/features/auth/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const LoginForm = ({
</FormField>
<Flex>
<Button
isLoading={login.isLoading || login.isSuccess}
isLoading={login.isPending || login.isSuccess}
type="submit"
variant={buttonVariant}
size="lg"
Expand Down
2 changes: 1 addition & 1 deletion src/features/auth/OAuthLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const OAuthLoginButton = ({
return (
<Button
onClick={() => loginWith.mutate({ provider: provider })}
isLoading={loginWith.isLoading || loginWith.isSuccess}
isLoading={loginWith.isPending || loginWith.isSuccess}
leftIcon={<Icon icon={OAUTH_PROVIDERS[provider].icon} />}
{...rest}
>
Expand Down
2 changes: 1 addition & 1 deletion src/features/auth/PageLoginValidate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function PageLoginValidate() {
<Form {...form} onSubmit={onSubmit}>
<VerificationCodeForm
email={email ?? ''}
isLoading={validate.isLoading || validate.isSuccess}
isLoading={validate.isPending || validate.isSuccess}
/>
</Form>
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion src/features/auth/PageRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default function PageRegister() {

<Flex>
<Button
isLoading={register.isLoading}
isLoading={register.isPending}
type="submit"
variant="@primary"
flex={1}
Expand Down
2 changes: 1 addition & 1 deletion src/features/auth/PageRegisterValidate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function PageRegisterValidate() {
<Form {...form} onSubmit={onSubmit}>
<VerificationCodeForm
email={email ?? ''}
isLoading={validate.isLoading || validate.isSuccess}
isLoading={validate.isPending || validate.isSuccess}
/>
</Form>
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion src/features/repositories/AdminRepositoryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const AdminRepositoryActions = ({

return (
<Menu placement="left-start" {...rest}>
<MenuButton as={ActionsButton} isLoading={repositoryRemove.isLoading} />
<MenuButton as={ActionsButton} isLoading={repositoryRemove.isPending} />
<Portal>
<MenuList>
<MenuItem
Expand Down
2 changes: 1 addition & 1 deletion src/features/repositories/PageAdminRepositories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function PageAdminRepositories() {
</HStack>

<DataList>
{repositories.isLoading && <DataListLoadingState />}
{repositories.isPending && <DataListLoadingState />}
{repositories.isError && (
<DataListErrorState
title={t('repositories:feedbacks.loadingRepositoryError.title')}
Expand Down
6 changes: 3 additions & 3 deletions src/features/repositories/PageAdminRepository.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ export default function PageAdminRepository() {
aria-label={t('common:actions.delete')}
icon={<LuTrash2 />}
isDisabled={!repository.data}
isLoading={repositoryRemove.isLoading}
isLoading={repositoryRemove.isPending}
/>
</ConfirmModal>
</>
}
>
{repository.isLoading && <SkeletonText maxW="6rem" noOfLines={2} />}
{repository.isPending && <SkeletonText maxW="6rem" noOfLines={2} />}
{repository.isSuccess && (
<Heading size="sm">{repository.data?.name}</Heading>
)}
</AdminLayoutPageTopBar>
<AdminLayoutPageContent>
{repository.isLoading && <LoaderFull />}
{repository.isPending && <LoaderFull />}
{repository.isError && <ErrorPage />}
{repository.isSuccess && (
<Card>
Expand Down
2 changes: 1 addition & 1 deletion src/features/repositories/PageAdminRepositoryCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function PageAdminRepositoryCreate() {
type="submit"
variant="@primary"
isLoading={
createRepository.isLoading || createRepository.isSuccess
createRepository.isPending || createRepository.isSuccess
}
>
{t('repositories:create.action.save')}
Expand Down
4 changes: 2 additions & 2 deletions src/features/repositories/PageAdminRepositoryUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default function PageAdminRepositoryUpdate() {
type="submit"
variant="@primary"
isLoading={
updateRepository.isLoading || updateRepository.isSuccess
updateRepository.isPending || updateRepository.isSuccess
}
>
{t('repositories:update.action.save')}
Expand All @@ -104,7 +104,7 @@ export default function PageAdminRepositoryUpdate() {
}
>
<Stack flex={1} spacing={0}>
{repository.isLoading && <SkeletonText maxW="6rem" noOfLines={2} />}
{repository.isPending && <SkeletonText maxW="6rem" noOfLines={2} />}
{repository.isSuccess && (
<Heading size="sm">{repository.data?.name}</Heading>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/features/repositories/PageRepositories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function PageRepositories() {
<Stack flex={1} spacing={4}>
<Heading size="md">{t('repositories:list.title')}</Heading>

{repositories.isLoading && <LoaderFull />}
{repositories.isPending && <LoaderFull />}
{repositories.isError && <ErrorPage />}

{repositories.isSuccess &&
Expand Down
7 changes: 3 additions & 4 deletions src/features/repositories/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ export const zRepository = () =>
.nonEmpty(z.string(), {
required_error: t('repositories:data.link.required'),
})
.transform((v) => (v.startsWith('http') ? v : `https://${v}`))
.pipe(
z
.string()
.min(4, t('repositories:data.link.tooSmall', { min: 4 }))
.min(8, t('repositories:data.link.tooSmall', { min: 4 }))
DecampsRenan marked this conversation as resolved.
Show resolved Hide resolved
.includes('.', { message: t('repositories:data.link.missingDot') })
)
.transform((v) => (v.startsWith('http') ? v : `https://${v}`)),
),
Comment on lines +18 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Resolve the mismatch between min length and error message.
The minimum length has been set to 8, yet the error message param uses { min: 4 }. This discrepancy might confuse users and lead to incorrect translations or error notifications.

A suggested fix:

 .transform((v) => (v.startsWith('http') ? v : `https://${v}`))
 .pipe(
   z
     .string()
-    .min(8, t('repositories:data.link.tooSmall', { min: 4 }))
+    .min(8, t('repositories:data.link.tooSmall', { min: 8 }))
     .includes('.', { message: t('repositories:data.link.missingDot') })
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.transform((v) => (v.startsWith('http') ? v : `https://${v}`))
.pipe(
z
.string()
.min(4, t('repositories:data.link.tooSmall', { min: 4 }))
.min(8, t('repositories:data.link.tooSmall', { min: 4 }))
.includes('.', { message: t('repositories:data.link.missingDot') })
)
.transform((v) => (v.startsWith('http') ? v : `https://${v}`)),
),
.transform((v) => (v.startsWith('http') ? v : `https://${v}`))
.pipe(
z
.string()
.min(8, t('repositories:data.link.tooSmall', { min: 8 }))
.includes('.', { message: t('repositories:data.link.missingDot') })
),

description: zu.string.nonEmptyNullable(z.string()),
});

export type FormFieldsRepository = z.infer<
ReturnType<typeof zFormFieldsRepository>
>;
Expand Down
2 changes: 1 addition & 1 deletion src/features/users/AdminUserActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const AdminUserActions = ({ user, ...rest }: AdminUserActionProps) => {
});

const isLoading =
activateUser.isLoading || deactivateUser.isLoading || removeUser.isLoading;
activateUser.isPending || deactivateUser.isPending || removeUser.isPending;

return (
<Menu placement="left-start" {...rest}>
Expand Down
2 changes: 1 addition & 1 deletion src/features/users/PageAdminUserCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function PageAdminUserCreate() {
<Button
type="submit"
variant="@primary"
isLoading={createUser.isLoading || createUser.isSuccess}
isLoading={createUser.isPending || createUser.isSuccess}
>
{t('users:create.action.save')}
</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/features/users/PageAdminUserUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ export default function PageAdminUserUpdate() {
<Button
type="submit"
variant="@primary"
isLoading={userUpdate.isLoading || userUpdate.isSuccess}
isLoading={userUpdate.isPending || userUpdate.isSuccess}
>
{t('users:update.action.save')}
</Button>
</>
}
>
{user.isLoading || user.isError ? (
{user.isPending || user.isError ? (
<SkeletonText maxW="6rem" noOfLines={2} />
) : (
<Flex
Expand Down
2 changes: 1 addition & 1 deletion src/features/users/PageAdminUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default function PageAdminUsers() {
</HStack>

<DataList>
{users.isLoading && <DataListLoadingState />}
{users.isPending && <DataListLoadingState />}
{users.isError && (
<DataListErrorState
title={t('users:feedbacks.loadingUserError.title')}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/trpc/TrpcProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export function TrpcProvider(props: { children: React.ReactNode }) {
}),
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
transformer: superjson,
}),
],
transformer: superjson,
})
);
return (
Expand Down
4 changes: 4 additions & 0 deletions src/lib/zod/zod-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const zu = {
return z
.literal('')
.transform(() => null)
.pipe(z.null())
.or(zu.string.nonEmpty(s, options).nullable());
},
nonEmptyNullish(
Expand All @@ -37,6 +38,7 @@ export const zu = {
return z
.literal('')
.transform(() => null)
.pipe(z.null())
.or(zu.string.nonEmpty(s, options).nullish());
},
email(
Expand Down Expand Up @@ -80,12 +82,14 @@ export const zu = {
return a
.length(0)
.transform(() => null)
.pipe(z.null())
.or(zu.array.nonEmpty(a, message).nullable());
},
nonEmptyNullish<T extends Schema>(a: ZodArray<T>, message?: string) {
return a
.length(0)
.transform(() => null)
.pipe(z.null())
.or(zu.array.nonEmpty(a, message).nullish());
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/server/config/openapi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateOpenApiDocument } from 'trpc-openapi';
import { generateOpenApiDocument } from 'trpc-to-openapi';

import { env } from '@/env.mjs';
import { appRouter } from '@/server/router';
Expand Down
Loading
Loading