Update tRPC and React-query (#748)

* Update tRPC and TypeScript

* Fix return types to fix types after the update

* Add changesets

* Use an exact version

* Update react query
This commit is contained in:
Krzysztof Wolski 2023-07-11 21:32:58 +02:00 committed by GitHub
parent e7c2d3a877
commit 62104473b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 354 additions and 534 deletions

View file

@ -0,0 +1,12 @@
---
"saleor-app-emails-and-messages": patch
"saleor-app-products-feed": patch
"saleor-app-invoices": patch
"saleor-app-klaviyo": patch
"@saleor/apps-ui": patch
"saleor-app-slack": patch
"saleor-app-taxes": patch
"saleor-app-crm": patch
---
Updated tRPC packages to 10.34.0

View file

@ -0,0 +1,10 @@
---
"saleor-app-emails-and-messages": patch
"saleor-app-products-feed": patch
"saleor-app-invoices": patch
"saleor-app-search": patch
"saleor-app-taxes": patch
"saleor-app-crm": patch
---
Updated @tanstack/react-query 4.29.19

View file

@ -17,11 +17,11 @@
"@saleor/apps-shared": "workspace:*", "@saleor/apps-shared": "workspace:*",
"@saleor/macaw-ui": "0.8.0-pre.95", "@saleor/macaw-ui": "0.8.0-pre.95",
"@sentry/nextjs": "7.55.2", "@sentry/nextjs": "7.55.2",
"@tanstack/react-query": "^4.28.0", "@tanstack/react-query": "4.29.19",
"@trpc/client": "^10.18.0", "@trpc/client": "10.34.0",
"@trpc/next": "^10.18.0", "@trpc/next": "10.34.0",
"@trpc/react-query": "^10.18.0", "@trpc/react-query": "10.34.0",
"@trpc/server": "^10.18.0", "@trpc/server": "10.34.0",
"@urql/exchange-auth": "^2.1.4", "@urql/exchange-auth": "^2.1.4",
"@vitejs/plugin-react": "4.0.0", "@vitejs/plugin-react": "4.0.0",
"clsx": "^1.2.1", "clsx": "^1.2.1",

View file

@ -22,11 +22,11 @@
"@sendgrid/client": "^7.7.0", "@sendgrid/client": "^7.7.0",
"@sendgrid/mail": "^7.7.0", "@sendgrid/mail": "^7.7.0",
"@sentry/nextjs": "7.55.2", "@sentry/nextjs": "7.55.2",
"@tanstack/react-query": "^4.24.4", "@tanstack/react-query": "4.29.19",
"@trpc/client": "^10.13.0", "@trpc/client": "10.34.0",
"@trpc/next": "^10.13.0", "@trpc/next": "10.34.0",
"@trpc/react-query": "^10.13.0", "@trpc/react-query": "10.34.0",
"@trpc/server": "^10.13.0", "@trpc/server": "10.34.0",
"@urql/exchange-auth": "^2.1.4", "@urql/exchange-auth": "^2.1.4",
"@vitejs/plugin-react": "4.0.0", "@vitejs/plugin-react": "4.0.0",
"clsx": "^1.2.1", "clsx": "^1.2.1",
@ -45,7 +45,6 @@
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-hook-form": "^7.43.9", "react-hook-form": "^7.43.9",
"react-is": "^18.2.0", "react-is": "^18.2.0",
"react-query": "^3.39.3",
"urql": "^4.0.4", "urql": "^4.0.4",
"usehooks-ts": "^2.9.1", "usehooks-ts": "^2.9.1",
"vite": "4.3.9", "vite": "4.3.9",

View file

@ -68,7 +68,7 @@ export const sendgridConfigurationRouter = router({
try { try {
return ctx.sendgridConfigurationService.getConfiguration(input); return ctx.sendgridConfigurationService.getConfiguration(input);
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
getConfigurations: protectedWithConfigurationServices getConfigurations: protectedWithConfigurationServices
@ -81,7 +81,7 @@ export const sendgridConfigurationRouter = router({
try { try {
return ctx.sendgridConfigurationService.getConfigurations(input); return ctx.sendgridConfigurationService.getConfigurations(input);
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
createConfiguration: protectedWithConfigurationServices createConfiguration: protectedWithConfigurationServices
@ -109,7 +109,7 @@ export const sendgridConfigurationRouter = router({
try { try {
await ctx.sendgridConfigurationService.deleteConfiguration(input); await ctx.sendgridConfigurationService.deleteConfiguration(input);
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
getEventConfiguration: protectedWithConfigurationServices getEventConfiguration: protectedWithConfigurationServices
@ -126,7 +126,7 @@ export const sendgridConfigurationRouter = router({
eventType: input.eventType, eventType: input.eventType,
}); });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
updateBasicInformation: protectedWithConfigurationServices updateBasicInformation: protectedWithConfigurationServices
@ -140,7 +140,7 @@ export const sendgridConfigurationRouter = router({
try { try {
return await ctx.sendgridConfigurationService.updateConfiguration({ ...input }); return await ctx.sendgridConfigurationService.updateConfiguration({ ...input });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
updateApiConnection: protectedWithConfigurationServices updateApiConnection: protectedWithConfigurationServices
@ -154,7 +154,7 @@ export const sendgridConfigurationRouter = router({
try { try {
return await ctx.sendgridConfigurationService.updateConfiguration({ ...input }); return await ctx.sendgridConfigurationService.updateConfiguration({ ...input });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
@ -192,7 +192,7 @@ export const sendgridConfigurationRouter = router({
sender: input.sender, sender: input.sender,
}); });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
updateChannels: protectedWithConfigurationServices updateChannels: protectedWithConfigurationServices
@ -213,7 +213,7 @@ export const sendgridConfigurationRouter = router({
}, },
}); });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
@ -234,7 +234,7 @@ export const sendgridConfigurationRouter = router({
eventConfiguration, eventConfiguration,
}); });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
@ -256,7 +256,7 @@ export const sendgridConfigurationRouter = router({
events: input.events, events: input.events,
}); });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
}); });

View file

@ -71,7 +71,7 @@ export const smtpConfigurationRouter = router({
try { try {
return ctx.smtpConfigurationService.getConfiguration(input); return ctx.smtpConfigurationService.getConfiguration(input);
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
getConfigurations: protectedWithConfigurationServices getConfigurations: protectedWithConfigurationServices
@ -84,7 +84,7 @@ export const smtpConfigurationRouter = router({
try { try {
return ctx.smtpConfigurationService.getConfigurations(input); return ctx.smtpConfigurationService.getConfigurations(input);
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
createConfiguration: protectedWithConfigurationServices createConfiguration: protectedWithConfigurationServices
@ -102,7 +102,7 @@ export const smtpConfigurationRouter = router({
try { try {
return await ctx.smtpConfigurationService.createConfiguration(newConfiguration); return await ctx.smtpConfigurationService.createConfiguration(newConfiguration);
} catch (e) { } catch (e) {
console.log("erroro", e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
deleteConfiguration: protectedWithConfigurationServices deleteConfiguration: protectedWithConfigurationServices
@ -116,7 +116,7 @@ export const smtpConfigurationRouter = router({
try { try {
await ctx.smtpConfigurationService.deleteConfiguration(input); await ctx.smtpConfigurationService.deleteConfiguration(input);
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
getEventConfiguration: protectedWithConfigurationServices getEventConfiguration: protectedWithConfigurationServices
@ -133,7 +133,7 @@ export const smtpConfigurationRouter = router({
eventType: input.eventType, eventType: input.eventType,
}); });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
@ -192,7 +192,7 @@ export const smtpConfigurationRouter = router({
try { try {
return await ctx.smtpConfigurationService.updateConfiguration({ ...input }); return await ctx.smtpConfigurationService.updateConfiguration({ ...input });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
@ -207,7 +207,7 @@ export const smtpConfigurationRouter = router({
try { try {
return await ctx.smtpConfigurationService.updateConfiguration({ ...input }); return await ctx.smtpConfigurationService.updateConfiguration({ ...input });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
@ -222,7 +222,7 @@ export const smtpConfigurationRouter = router({
try { try {
return await ctx.smtpConfigurationService.updateConfiguration({ ...input }); return await ctx.smtpConfigurationService.updateConfiguration({ ...input });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
@ -244,7 +244,7 @@ export const smtpConfigurationRouter = router({
}, },
}); });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
@ -265,7 +265,7 @@ export const smtpConfigurationRouter = router({
eventConfiguration, eventConfiguration,
}); });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
updateEventArray: protectedWithConfigurationServices updateEventArray: protectedWithConfigurationServices
@ -286,7 +286,7 @@ export const smtpConfigurationRouter = router({
events: input.events, events: input.events,
}); });
} catch (e) { } catch (e) {
throwTrpcErrorFromConfigurationServiceError(e); return throwTrpcErrorFromConfigurationServiceError(e);
} }
}), }),
}); });

View file

@ -3,7 +3,7 @@ import { createTRPCNext } from "@trpc/next";
import { SALEOR_API_URL_HEADER, SALEOR_AUTHORIZATION_BEARER_HEADER } from "@saleor/app-sdk/const"; import { SALEOR_API_URL_HEADER, SALEOR_AUTHORIZATION_BEARER_HEADER } from "@saleor/app-sdk/const";
import { appBridgeInstance } from "../../pages/_app"; import { appBridgeInstance } from "../../pages/_app";
import { AppRouter } from "./trpc-app-router"; import type { AppRouter } from "./trpc-app-router";
function getBaseUrl() { function getBaseUrl() {
if (typeof window !== "undefined") return ""; if (typeof window !== "undefined") return "";
@ -20,6 +20,7 @@ export const trpcClient = createTRPCNext<AppRouter>({
url: `${getBaseUrl()}/api/trpc`, url: `${getBaseUrl()}/api/trpc`,
headers() { headers() {
const { token, saleorApiUrl } = appBridgeInstance?.getState() || {}; const { token, saleorApiUrl } = appBridgeInstance?.getState() || {};
if (!token || !saleorApiUrl) { if (!token || !saleorApiUrl) {
console.error( console.error(
"Can't initialize tRPC client before establishing the App Bridge connection" "Can't initialize tRPC client before establishing the App Bridge connection"

View file

@ -17,11 +17,11 @@
"@saleor/apps-shared": "workspace:*", "@saleor/apps-shared": "workspace:*",
"@saleor/macaw-ui": "0.8.0-pre.95", "@saleor/macaw-ui": "0.8.0-pre.95",
"@sentry/nextjs": "7.55.2", "@sentry/nextjs": "7.55.2",
"@tanstack/react-query": "^4.24.4", "@tanstack/react-query": "4.29.19",
"@trpc/client": "^10.10.0", "@trpc/client": "10.34.0",
"@trpc/next": "^10.10.0", "@trpc/next": "10.34.0",
"@trpc/react-query": "^10.10.0", "@trpc/react-query": "10.34.0",
"@trpc/server": "^10.10.0", "@trpc/server": "10.34.0",
"@urql/exchange-auth": "^2.1.4", "@urql/exchange-auth": "^2.1.4",
"@web-std/file": "^3.0.2", "@web-std/file": "^3.0.2",
"clsx": "^1.2.1", "clsx": "^1.2.1",

View file

@ -20,11 +20,11 @@
"@saleor/macaw-ui": "0.8.0-pre.95", "@saleor/macaw-ui": "0.8.0-pre.95",
"@saleor/react-hook-form-macaw": "workspace:*", "@saleor/react-hook-form-macaw": "workspace:*",
"@sentry/nextjs": "7.55.2", "@sentry/nextjs": "7.55.2",
"@tanstack/react-query": "^4.24.2", "@tanstack/react-query": "4.29.19",
"@trpc/client": "^10.9.0", "@trpc/client": "10.34.0",
"@trpc/next": "^10.9.0", "@trpc/next": "10.34.0",
"@trpc/react-query": "^10.9.0", "@trpc/react-query": "10.34.0",
"@trpc/server": "^10.9.0", "@trpc/server": "10.34.0",
"@urql/exchange-auth": "^2.1.4", "@urql/exchange-auth": "^2.1.4",
"@vitejs/plugin-react": "4.0.0", "@vitejs/plugin-react": "4.0.0",
"clsx": "^1.2.1", "clsx": "^1.2.1",
@ -39,7 +39,6 @@
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-hook-form": "^7.43.9", "react-hook-form": "^7.43.9",
"react-is": "^18.2.0", "react-is": "^18.2.0",
"react-query": "^3.39.3",
"urql": "^4.0.4", "urql": "^4.0.4",
"usehooks-ts": "^2.9.1", "usehooks-ts": "^2.9.1",
"vite": "4.3.9", "vite": "4.3.9",

View file

@ -2,7 +2,7 @@ import "@saleor/macaw-ui/next/style";
import { AppBridge, AppBridgeProvider } from "@saleor/app-sdk/app-bridge"; import { AppBridge, AppBridgeProvider } from "@saleor/app-sdk/app-bridge";
import React from "react"; import React from "react";
import { AppProps } from "next/app"; import { AppProps } from "next/app";
import { QueryClient, QueryClientProvider } from "react-query"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { RoutePropagator } from "@saleor/app-sdk/app-bridge/next"; import { RoutePropagator } from "@saleor/app-sdk/app-bridge/next";
import { ThemeSynchronizer } from "../lib/theme-synchronizer"; import { ThemeSynchronizer } from "../lib/theme-synchronizer";
import { Box, ThemeProvider } from "@saleor/macaw-ui/next"; import { Box, ThemeProvider } from "@saleor/macaw-ui/next";

View file

@ -19,6 +19,7 @@
"@saleor/macaw-ui": "0.8.0-pre.95", "@saleor/macaw-ui": "0.8.0-pre.95",
"@saleor/react-hook-form-macaw": "workspace:*", "@saleor/react-hook-form-macaw": "workspace:*",
"@sentry/nextjs": "7.55.2", "@sentry/nextjs": "7.55.2",
"@tanstack/react-query": "4.29.19",
"@types/debug": "^4.1.7", "@types/debug": "^4.1.7",
"@urql/exchange-auth": "^2.1.4", "@urql/exchange-auth": "^2.1.4",
"algoliasearch": "4.14.2", "algoliasearch": "4.14.2",
@ -33,7 +34,6 @@
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-helmet": "^6.1.0", "react-helmet": "^6.1.0",
"react-hook-form": "^7.43.9", "react-hook-form": "^7.43.9",
"react-query": "^3.39.3",
"urql": "^4.0.4", "urql": "^4.0.4",
"zod": "^3.20.2" "zod": "^3.20.2"
}, },

View file

@ -1,7 +1,7 @@
import { useAuthenticatedFetch } from "@saleor/app-sdk/app-bridge"; import { useAuthenticatedFetch } from "@saleor/app-sdk/app-bridge";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
import { useMutation, useQuery, useQueryClient } from "react-query"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { fetchConfiguration } from "../lib/configuration"; import { fetchConfiguration } from "../lib/configuration";
import { Box, Button, Divider, Text } from "@saleor/macaw-ui/next"; import { Box, Button, Divider, Text } from "@saleor/macaw-ui/next";
import { Input } from "@saleor/react-hook-form-macaw"; import { Input } from "@saleor/react-hook-form-macaw";

View file

@ -1,4 +1,4 @@
import { useQuery } from "react-query"; import { useQuery } from "@tanstack/react-query";
import { useAuthenticatedFetch } from "@saleor/app-sdk/app-bridge"; import { useAuthenticatedFetch } from "@saleor/app-sdk/app-bridge";
import { AppConfigurationFields } from "../domain/configuration"; import { AppConfigurationFields } from "../domain/configuration";

View file

@ -1,4 +1,4 @@
import { useQuery } from "react-query"; import { useQuery } from "@tanstack/react-query";
import { useAuthenticatedFetch } from "@saleor/app-sdk/app-bridge"; import { useAuthenticatedFetch } from "@saleor/app-sdk/app-bridge";
import { useCallback } from "react"; import { useCallback } from "react";
import { OwnWebhookFragment } from "../../generated/graphql"; import { OwnWebhookFragment } from "../../generated/graphql";
@ -14,7 +14,7 @@ export const useWebhooksStatus = () => {
}, []); }, []);
return useQuery<OwnWebhookFragment[]>({ return useQuery<OwnWebhookFragment[]>({
queryKey: "webhooks-status", queryKey: ["webhooks-status"],
queryFn: fetchFn, queryFn: fetchFn,
}); });
}; };

View file

@ -1,10 +1,10 @@
import "../styles/globals.css"; import "../styles/globals.css";
import "@saleor/macaw-ui/next/style"; import "@saleor/macaw-ui/next/style";
import { AppBridge, AppBridgeProvider } from "@saleor/app-sdk/app-bridge"; import { AppBridge, AppBridgeProvider } from "@saleor/app-sdk/app-bridge";
import React, { useEffect } from "react"; import React from "react";
import { AppProps } from "next/app"; import { AppProps } from "next/app";
import { GraphQLProvider } from "../providers/GraphQLProvider"; import { GraphQLProvider } from "../providers/GraphQLProvider";
import { QueryClient, QueryClientProvider } from "react-query"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { RoutePropagator } from "@saleor/app-sdk/app-bridge/next"; import { RoutePropagator } from "@saleor/app-sdk/app-bridge/next";
import { ThemeSynchronizer } from "../lib/theme-synchronizer"; import { ThemeSynchronizer } from "../lib/theme-synchronizer";
import { Box, ThemeProvider } from "@saleor/macaw-ui/next"; import { Box, ThemeProvider } from "@saleor/macaw-ui/next";

View file

@ -19,11 +19,11 @@
"@saleor/macaw-ui": "^0.8.0-pre.84", "@saleor/macaw-ui": "^0.8.0-pre.84",
"@saleor/react-hook-form-macaw": "workspace:*", "@saleor/react-hook-form-macaw": "workspace:*",
"@sentry/nextjs": "7.55.2", "@sentry/nextjs": "7.55.2",
"@tanstack/react-query": "^4.19.1", "@tanstack/react-query": "4.29.19",
"@trpc/client": "^10.9.0", "@trpc/client": "10.34.0",
"@trpc/next": "^10.9.0", "@trpc/next": "10.34.0",
"@trpc/react-query": "^10.9.0", "@trpc/react-query": "10.34.0",
"@trpc/server": "^10.9.0", "@trpc/server": "10.34.0",
"@urql/exchange-auth": "^2.1.4", "@urql/exchange-auth": "^2.1.4",
"avatax": "^23.3.2", "avatax": "^23.3.2",
"clsx": "^1.2.1", "clsx": "^1.2.1",

File diff suppressed because it is too large Load diff