@creatorem/next-trpc 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import type { useQuery as useQueryType } from "@tanstack/react-query";
2
2
  import { type EndpointClient, createTrpcClientOptions } from "./create-trpc-client";
3
3
  import type { Router, Endpoint, router } from "./core";
4
4
  import z from "zod";
5
- type TrpcClientWithQuery<R extends Router<any>> = {
5
+ export type TrpcClientWithQuery<R extends Router<any>> = {
6
6
  [K in keyof R]: R[K] extends Endpoint<infer Output, infer Input, any> ? EndpointClient<Input, Output> & {
7
7
  useQuery: Input extends import("zod").Schema ? (queryOptions: Omit<Parameters<typeof useQueryType>[0], "queryKey" | "queryFn"> & {
8
8
  input: z.infer<Input>;
@@ -12,4 +12,3 @@ type TrpcClientWithQuery<R extends Router<any>> = {
12
12
  export declare const createTrpcQueryClient: <R extends ReturnType<typeof router<any, Router<any>>>>(opts: createTrpcClientOptions & {
13
13
  useQuery: typeof useQueryType;
14
14
  }) => TrpcClientWithQuery<R>;
15
- export {};
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.createTrpcQueryClient = void 0;
5
5
  const create_trpc_client_1 = require("./create-trpc-client");
6
+ const utils_1 = require("./utils");
6
7
  const createTrpcQueryClient = (opts) => {
7
8
  return new Proxy({}, {
8
9
  get(target, prop) {
@@ -10,12 +11,13 @@ const createTrpcQueryClient = (opts) => {
10
11
  return {
11
12
  fetch: (0, create_trpc_client_1.getTrpcFetch)(Object.assign({ endpointSlug: prop }, opts)),
12
13
  useQuery: (queryOptions) => {
13
- const endpointName = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
14
+ const endpointName = (0, utils_1.kebabize)(prop);
14
15
  return opts.useQuery(Object.assign(Object.assign({}, queryOptions), { queryKey: [endpointName], queryFn: async () => {
15
16
  const fetcher = (0, create_trpc_client_1.getTrpcFetch)(Object.assign({ endpointSlug: prop }, opts));
16
17
  return await fetcher(queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.input);
17
18
  } }));
18
19
  },
20
+ key: (0, utils_1.kebabize)(prop)
19
21
  };
20
22
  }
21
23
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creatorem/next-trpc",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/creatorem/next-trpc"