@creatorem/next-trpc 1.0.1 → 1.0.5

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.
package/dist/utils.js CHANGED
@@ -1,2 +1,7 @@
1
- export const kebabize = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
2
- export const camelize = (s) => s.replace(/-./g, (x) => x[1].toUpperCase());
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.camelize = exports.kebabize = void 0;
4
+ const kebabize = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
5
+ exports.kebabize = kebabize;
6
+ const camelize = (s) => s.replace(/-./g, (x) => x[1].toUpperCase());
7
+ exports.camelize = camelize;
package/package.json CHANGED
@@ -1,12 +1,21 @@
1
1
  {
2
2
  "name": "@creatorem/next-trpc",
3
- "private": false,
4
- "version": "1.0.1",
3
+ "version": "1.0.5",
4
+ "type": "module",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/creatorem/next-trpc"
8
+ },
5
9
  "homepage": "https://creatorem.com",
6
10
  "author": {
7
11
  "url": "https://creatorem.com",
8
12
  "name": "Creatorem"
9
13
  },
14
+ "keywords": [
15
+ "nextjs",
16
+ "trpc",
17
+ "typescript"
18
+ ],
10
19
  "license": "MIT",
11
20
  "publishConfig": {
12
21
  "access": "public"
@@ -15,24 +24,29 @@
15
24
  "dist"
16
25
  ],
17
26
  "exports": {
18
- "./": {
27
+ ".": {
28
+ "import": "./dist/core.js",
19
29
  "require": "./dist/core.js",
20
30
  "types": "./dist/core.d.ts"
21
31
  },
22
32
  "./server": {
23
- "require": "./dist/create-rpc-api.js",
24
- "types": "./dist/create-rpc-api.d.ts"
33
+ "import": "./dist/create-trpc-api.js",
34
+ "require": "./dist/create-trpc-api.js",
35
+ "types": "./dist/create-trpc-api.d.ts"
25
36
  },
26
37
  "./client": {
27
- "require": "./dist/create-rpc-client.js",
28
- "types": "./dist/create-rpc-client.d.ts"
38
+ "import": "./dist/create-trpc-client.js",
39
+ "require": "./dist/create-trpc-client.js",
40
+ "types": "./dist/create-trpc-client.d.ts"
29
41
  },
30
42
  "./query-client": {
31
- "require": "./dist/create-rpc-query-client.js",
32
- "types": "./dist/create-rpc-query-client.d.ts"
43
+ "import": "./dist/create-trpc-query-client.js",
44
+ "require": "./dist/create-trpc-query-client.js",
45
+ "types": "./dist/create-trpc-query-client.d.ts"
33
46
  }
34
47
  },
35
48
  "devDependencies": {
49
+ "turbo": "^2.6.3",
36
50
  "typescript": "~5.9.2"
37
51
  },
38
52
  "peerDependencies": {
@@ -43,13 +57,13 @@
43
57
  "typesVersions": {
44
58
  "*": {
45
59
  "*": [
46
- "src/*"
60
+ "dist/*"
47
61
  ]
48
62
  }
49
63
  },
50
64
  "scripts": {
51
- "build": "tsc --noEmit false --outDir dist --declaration",
52
- "clean": "git clean -xdf .turbo node_modules",
65
+ "build": "tsc --noEmit false --outDir dist --declaration --module commonjs --target ES2017",
66
+ "clean": "git clean -xdf .turbo dist node_modules",
53
67
  "format": "prettier --check \"**/*.{ts,tsx}\"",
54
68
  "lint": "eslint .",
55
69
  "typecheck": "tsc --noEmit",
@@ -1,17 +0,0 @@
1
- import { Router, type Endpoint, type router } from "./core";
2
- type RpcClient<R extends Router<any>> = {
3
- [K in keyof R]: R[K] extends Endpoint<infer Output, infer Input, any> ? Input extends undefined ? {
4
- fetch: () => Promise<Output>;
5
- } : {
6
- fetch: (input: Input extends import("zod").Schema ? import("zod").infer<Input> : Input) => Promise<Output>;
7
- } : never;
8
- };
9
- export declare const getRpcFetch: ({ endpointSlug, url, headers, }: {
10
- endpointSlug: string;
11
- } & CreateRpcClientOptions) => (input?: any) => Promise<any>;
12
- export interface CreateRpcClientOptions {
13
- url: string;
14
- headers: HeadersInit | (() => Promise<HeadersInit>);
15
- }
16
- export declare const createRpcClient: <R extends ReturnType<typeof router<any, Router<any>>>>(opts: CreateRpcClientOptions) => RpcClient<R>;
17
- export {};
@@ -1,14 +0,0 @@
1
- import { useQuery } from "@tanstack/react-query";
2
- import { CreateRpcClientOptions } from "./create-rpc-client";
3
- import { Router, type Endpoint, type router } from "./core";
4
- type RpcClient<R extends Router<any>> = {
5
- [K in keyof R]: R[K] extends Endpoint<infer Output, infer Input, any> ? Input extends undefined ? {
6
- fetch: () => Promise<Output>;
7
- useQuery: (queryOptions?: Omit<Parameters<typeof useQuery>[0], "queryKey" | "queryFn">) => ReturnType<typeof useQuery<Promise<Output>, Error, Promise<Output>, string[]>>;
8
- } : {
9
- fetch: (input: Input extends import("zod").Schema ? import("zod").infer<Input> : Input) => Promise<Output>;
10
- useQuery: (queryOptions?: Omit<Parameters<typeof useQuery>[0], "queryKey" | "queryFn">) => ReturnType<typeof useQuery<Promise<Output>, Error, Promise<Output>, string[]>>;
11
- } : never;
12
- };
13
- export declare const createRpcQueryClient: <R extends ReturnType<typeof router<any, Router<any>>>>(opts: CreateRpcClientOptions) => RpcClient<R>;
14
- export {};
@@ -1,19 +0,0 @@
1
- "use client";
2
- import { useQuery } from "@tanstack/react-query";
3
- import { getRpcFetch } from "./create-rpc-client";
4
- export const createRpcQueryClient = (opts) => {
5
- return new Proxy({}, {
6
- get(target, prop) {
7
- if (typeof prop === "string") {
8
- return {
9
- fetch: getRpcFetch(Object.assign({ endpointSlug: prop }, opts)),
10
- useQuery: (queryOptions) => {
11
- const endpointName = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
12
- return useQuery(Object.assign(Object.assign({}, queryOptions), { queryKey: [endpointName], queryFn: getRpcFetch(Object.assign({ endpointSlug: prop }, opts)) }));
13
- },
14
- };
15
- }
16
- return undefined;
17
- },
18
- });
19
- };