@trpc/react-query 10.18.0 → 10.19.0
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/README.md +3 -3
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/{ssg → server}/index.js +4 -5
- package/dist/{ssg → server}/index.mjs +4 -4
- package/dist/{ssg → server}/ssgProxy.d.ts +2 -2
- package/dist/server/ssgProxy.d.ts.map +1 -0
- package/dist/server/types.d.ts +10 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/ssg/index.d.ts +13 -3
- package/dist/ssg/index.d.ts.map +1 -1
- package/dist/ssg/ssg.d.ts +3 -10
- package/dist/ssg/ssg.d.ts.map +1 -1
- package/package.json +19 -13
- package/server/index.d.ts +1 -0
- package/server/index.js +1 -0
- package/src/server/index.ts +4 -0
- package/src/{ssg → server}/ssgProxy.ts +5 -4
- package/src/server/types.ts +14 -0
- package/src/shared/proxy/utilsProxy.ts +1 -1
- package/src/ssg/index.tsx +16 -0
- package/src/ssg/ssg.ts +3 -12
- package/dist/ssg/ssgProxy.d.ts.map +0 -1
- package/src/ssg/index.ts +0 -4
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ pnpm add @trpc/react-query @tanstack/react-query
|
|
|
38
38
|
Create a utils file that exports tRPC hooks and providers.
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
|
-
import {
|
|
41
|
+
import { createTRPCReact } from '@trpc/react-query';
|
|
42
42
|
import type { AppRouter } from './server';
|
|
43
43
|
|
|
44
44
|
export const trpc = createTRPCReact<AppRouter>();
|
|
@@ -72,10 +72,10 @@ export function App() {
|
|
|
72
72
|
Now in any component, you can query your API using the proxy exported from the utils file.
|
|
73
73
|
|
|
74
74
|
```ts
|
|
75
|
-
import {
|
|
75
|
+
import { trpc } from '~/utils/trpc';
|
|
76
76
|
|
|
77
77
|
export function Hello() {
|
|
78
|
-
const { data, error, status } =
|
|
78
|
+
const { data, error, status } = trpc.greeting.useQuery({ name: 'tRPC' });
|
|
79
79
|
|
|
80
80
|
if (error) {
|
|
81
81
|
return <p>{error.message}</p>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,YAAY,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,YAAY,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var shared = require('@trpc/server/shared');
|
|
5
6
|
var reactQuery = require('@tanstack/react-query');
|
|
6
7
|
var server = require('@trpc/server');
|
|
7
8
|
var getArrayQueryKey = require('../getArrayQueryKey-4bdb5cc2.js');
|
|
8
|
-
var shared = require('@trpc/server/shared');
|
|
9
9
|
require('@trpc/client');
|
|
10
10
|
require('react');
|
|
11
11
|
var queryClient = require('../queryClient-358a9a75.js');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Create functions you can use for server-side rendering / static generation
|
|
15
|
-
* @deprecated use `
|
|
15
|
+
* @deprecated use `createServerSideHelpers` instead
|
|
16
16
|
*/ function createSSGHelpers(opts) {
|
|
17
17
|
const { router , transformer , ctx } = opts;
|
|
18
18
|
const queryClient$1 = queryClient.getQueryClient(opts);
|
|
@@ -95,7 +95,7 @@ var queryClient = require('../queryClient-358a9a75.js');
|
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
97
|
* Create functions you can use for server-side rendering / static generation
|
|
98
|
-
*/ function
|
|
98
|
+
*/ function createServerSideHelpers(opts) {
|
|
99
99
|
const helpers = createSSGHelpers(opts);
|
|
100
100
|
return shared.createFlatProxy((key)=>{
|
|
101
101
|
if (key === 'queryClient') {
|
|
@@ -134,5 +134,4 @@ var queryClient = require('../queryClient-358a9a75.js');
|
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
exports.
|
|
138
|
-
exports.createSSGHelpers = createSSGHelpers;
|
|
137
|
+
exports.createServerSideHelpers = createServerSideHelpers;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared';
|
|
1
2
|
import { dehydrate } from '@tanstack/react-query';
|
|
2
3
|
import { callProcedure } from '@trpc/server';
|
|
3
4
|
import { g as getArrayQueryKey } from '../getArrayQueryKey-86134f8b.mjs';
|
|
4
|
-
import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared';
|
|
5
5
|
import '@trpc/client';
|
|
6
6
|
import 'react';
|
|
7
7
|
import { g as getQueryClient } from '../queryClient-4d766c0c.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Create functions you can use for server-side rendering / static generation
|
|
11
|
-
* @deprecated use `
|
|
11
|
+
* @deprecated use `createServerSideHelpers` instead
|
|
12
12
|
*/ function createSSGHelpers(opts) {
|
|
13
13
|
const { router , transformer , ctx } = opts;
|
|
14
14
|
const queryClient = getQueryClient(opts);
|
|
@@ -91,7 +91,7 @@ import { g as getQueryClient } from '../queryClient-4d766c0c.mjs';
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* Create functions you can use for server-side rendering / static generation
|
|
94
|
-
*/ function
|
|
94
|
+
*/ function createServerSideHelpers(opts) {
|
|
95
95
|
const helpers = createSSGHelpers(opts);
|
|
96
96
|
return createFlatProxy((key)=>{
|
|
97
97
|
if (key === 'queryClient') {
|
|
@@ -130,4 +130,4 @@ import { g as getQueryClient } from '../queryClient-4d766c0c.mjs';
|
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
export {
|
|
133
|
+
export { createServerSideHelpers };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DehydrateOptions, DehydratedState, InfiniteData, QueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { AnyProcedure, AnyQueryProcedure, AnyRouter, Filter, ProtectedIntersection, inferHandlerInput } from '@trpc/server';
|
|
3
3
|
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
4
|
-
import { CreateSSGHelpersOptions } from './
|
|
4
|
+
import { CreateSSGHelpersOptions } from './types';
|
|
5
5
|
declare type DecorateProcedure<TProcedure extends AnyProcedure> = {
|
|
6
6
|
/**
|
|
7
7
|
* @link https://react-query.tanstack.com/guides/prefetching
|
|
@@ -29,7 +29,7 @@ export declare type DecoratedProcedureSSGRecord<TRouter extends AnyRouter> = {
|
|
|
29
29
|
/**
|
|
30
30
|
* Create functions you can use for server-side rendering / static generation
|
|
31
31
|
*/
|
|
32
|
-
export declare function
|
|
32
|
+
export declare function createServerSideHelpers<TRouter extends AnyRouter>(opts: CreateSSGHelpersOptions<TRouter>): ProtectedIntersection<{
|
|
33
33
|
queryClient: QueryClient;
|
|
34
34
|
dehydrate: (opts?: DehydrateOptions) => DehydratedState;
|
|
35
35
|
}, DecoratedProcedureSSGRecord<TRouter>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssgProxy.d.ts","sourceRoot":"","sources":["../../src/server/ssgProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,MAAM,EACN,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,+BAA+B,EAChC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD,aAAK,iBAAiB,CAAC,UAAU,SAAS,YAAY,IAAI;IACxD;;OAEG;IACH,KAAK,CACH,GAAG,IAAI,EAAE,iBAAiB,CAAC,UAAU,CAAC,GACrC,OAAO,CAAC,+BAA+B,CAAC,UAAU,CAAC,CAAC,CAAC;IAExD;;OAEG;IACH,aAAa,CACX,GAAG,IAAI,EAAE,iBAAiB,CAAC,UAAU,CAAC,GACrC,OAAO,CAAC,YAAY,CAAC,+BAA+B,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAEtE;;OAEG;IACH,QAAQ,CAAC,GAAG,IAAI,EAAE,iBAAiB,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE;;OAEG;IACH,gBAAgB,CAAC,GAAG,IAAI,EAAE,iBAAiB,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzE,CAAC;AAEF;;GAEG;AACH,oBAAY,2BAA2B,CAAC,OAAO,SAAS,SAAS,IAAI;KAClE,IAAI,IAAI,MAAM,MAAM,CACnB,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACzB,SAAS,GAAG,iBAAiB,CAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GACjD,2BAA2B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,GAE5D,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAIF;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,SAAS,EAC/D,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC;iBAMrB,WAAW;uBACL,gBAAgB,KAAK,eAAe;yCAsC5D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AnyRouter, ClientDataTransformerOptions, inferRouterContext } from '@trpc/server';
|
|
2
|
+
import { CreateTRPCReactQueryClientConfig } from '../shared';
|
|
3
|
+
interface CreateSSGHelpersOptionsBase<TRouter extends AnyRouter> {
|
|
4
|
+
router: TRouter;
|
|
5
|
+
ctx: inferRouterContext<TRouter>;
|
|
6
|
+
transformer?: ClientDataTransformerOptions;
|
|
7
|
+
}
|
|
8
|
+
export declare type CreateSSGHelpersOptions<TRouter extends AnyRouter> = CreateSSGHelpersOptionsBase<TRouter> & CreateTRPCReactQueryClientConfig;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gCAAgC,EAAE,MAAM,WAAW,CAAC;AAE7D,UAAU,2BAA2B,CAAC,OAAO,SAAS,SAAS;IAC7D,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,4BAA4B,CAAC;CAC5C;AACD,oBAAY,uBAAuB,CAAC,OAAO,SAAS,SAAS,IAC3D,2BAA2B,CAAC,OAAO,CAAC,GAAG,gCAAgC,CAAC"}
|
package/dist/ssg/index.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
export {
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated use `@trpc/react/server` instead
|
|
4
|
+
*/
|
|
5
|
+
type CreateSSGHelpersOptions,
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use `@trpc/react/server` instead
|
|
8
|
+
*/
|
|
9
|
+
type DecoratedProcedureSSGRecord,
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use `import { createServerSideHelpers } from "@trpc/react/server"`;
|
|
12
|
+
*/
|
|
13
|
+
createServerSideHelpers as createProxySSGHelpers, } from '../server';
|
|
1
14
|
export { createSSGHelpers } from './ssg';
|
|
2
|
-
export type { CreateSSGHelpersOptions } from './ssg';
|
|
3
|
-
export { createProxySSGHelpers } from './ssgProxy';
|
|
4
|
-
export type { DecoratedProcedureSSGRecord } from './ssgProxy';
|
|
5
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ssg/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ssg/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ssg/index.tsx"],"names":[],"mappings":"AAAA,OAAO;AACL;;GAEG;AACH,KAAK,uBAAuB;AAC5B;;GAEG;AACH,KAAK,2BAA2B;AAChC;;GAEG;AACH,uBAAuB,IAAI,qBAAqB,GACjD,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC"}
|
package/dist/ssg/ssg.d.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { DehydrateOptions, DehydratedState, InfiniteData } from '@tanstack/react-query';
|
|
2
|
-
import { AnyRouter,
|
|
3
|
-
import {
|
|
4
|
-
interface CreateSSGHelpersOptionsBase<TRouter extends AnyRouter> {
|
|
5
|
-
router: TRouter;
|
|
6
|
-
ctx: inferRouterContext<TRouter>;
|
|
7
|
-
transformer?: ClientDataTransformerOptions;
|
|
8
|
-
}
|
|
9
|
-
export declare type CreateSSGHelpersOptions<TRouter extends AnyRouter> = CreateSSGHelpersOptionsBase<TRouter> & CreateTRPCReactQueryClientConfig;
|
|
2
|
+
import { AnyRouter, inferProcedureOutput } from '@trpc/server';
|
|
3
|
+
import { CreateSSGHelpersOptions } from '../server/types';
|
|
10
4
|
/**
|
|
11
5
|
* Create functions you can use for server-side rendering / static generation
|
|
12
|
-
* @deprecated use `
|
|
6
|
+
* @deprecated use `createServerSideHelpers` instead
|
|
13
7
|
*/
|
|
14
8
|
export declare function createSSGHelpers<TRouter extends AnyRouter>(opts: CreateSSGHelpersOptions<TRouter>): {
|
|
15
9
|
prefetchQuery: <TPath extends keyof TRouter["_def"]["queries"] & string, TProcedure extends TRouter["_def"]["queries"][TPath]>(path: TPath, ...args: import("@trpc/server").ProcedureArgs<import("@trpc/server").inferProcedureParams<TProcedure>>) => Promise<void>;
|
|
@@ -19,5 +13,4 @@ export declare function createSSGHelpers<TRouter extends AnyRouter>(opts: Create
|
|
|
19
13
|
dehydrate: (opts?: DehydrateOptions) => DehydratedState;
|
|
20
14
|
queryClient: import("@tanstack/react-query").QueryClient;
|
|
21
15
|
};
|
|
22
|
-
export {};
|
|
23
16
|
//# sourceMappingURL=ssg.d.ts.map
|
package/dist/ssg/ssg.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssg.d.ts","sourceRoot":"","sources":["../../src/ssg/ssg.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,YAAY,EAEb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,SAAS,
|
|
1
|
+
{"version":3,"file":"ssg.d.ts","sourceRoot":"","sources":["../../src/ssg/ssg.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,YAAY,EAEb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,SAAS,EAGT,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAG1D;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,SAAS,EACxD,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC;;;;;uBA6F9B,gBAAgB,KAMrB,eAAe;;EAcnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/react-query",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.19.0",
|
|
4
4
|
"description": "tRPC React lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"build": "rollup --config rollup.config.ts --configPlugin rollup-plugin-swc3",
|
|
18
18
|
"dev": "pnpm build --watch",
|
|
19
19
|
"codegen:entrypoints": "tsx entrypoints.script.ts",
|
|
20
|
-
"lint": "eslint --ext \".js,.ts,.tsx\" --ignore-path ../../.gitignore --report-unused-disable-directives src",
|
|
20
|
+
"lint": "eslint --cache --ext \".js,.ts,.tsx\" --ignore-path ../../.gitignore --report-unused-disable-directives src",
|
|
21
21
|
"ts-watch": "tsc --project tsconfig.watch.json"
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
@@ -27,15 +27,20 @@
|
|
|
27
27
|
"require": "./dist/index.js",
|
|
28
28
|
"default": "./dist/index.js"
|
|
29
29
|
},
|
|
30
|
-
"./
|
|
31
|
-
"import": "./dist/
|
|
32
|
-
"require": "./dist/
|
|
33
|
-
"default": "./dist/
|
|
30
|
+
"./server": {
|
|
31
|
+
"import": "./dist/server/index.mjs",
|
|
32
|
+
"require": "./dist/server/index.js",
|
|
33
|
+
"default": "./dist/server/index.js"
|
|
34
34
|
},
|
|
35
35
|
"./shared": {
|
|
36
36
|
"import": "./dist/shared/index.mjs",
|
|
37
37
|
"require": "./dist/shared/index.js",
|
|
38
38
|
"default": "./dist/shared/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./ssg": {
|
|
41
|
+
"import": "./dist/ssg/index.mjs",
|
|
42
|
+
"require": "./dist/ssg/index.js",
|
|
43
|
+
"default": "./dist/ssg/index.js"
|
|
39
44
|
}
|
|
40
45
|
},
|
|
41
46
|
"files": [
|
|
@@ -43,8 +48,9 @@
|
|
|
43
48
|
"src",
|
|
44
49
|
"README.md",
|
|
45
50
|
"package.json",
|
|
46
|
-
"
|
|
47
|
-
"shared"
|
|
51
|
+
"server",
|
|
52
|
+
"shared",
|
|
53
|
+
"ssg"
|
|
48
54
|
],
|
|
49
55
|
"eslintConfig": {
|
|
50
56
|
"rules": {
|
|
@@ -57,15 +63,15 @@
|
|
|
57
63
|
},
|
|
58
64
|
"peerDependencies": {
|
|
59
65
|
"@tanstack/react-query": "^4.18.0",
|
|
60
|
-
"@trpc/client": "10.
|
|
61
|
-
"@trpc/server": "10.
|
|
66
|
+
"@trpc/client": "10.19.0",
|
|
67
|
+
"@trpc/server": "10.19.0",
|
|
62
68
|
"react": ">=16.8.0",
|
|
63
69
|
"react-dom": ">=16.8.0"
|
|
64
70
|
},
|
|
65
71
|
"devDependencies": {
|
|
66
72
|
"@tanstack/react-query": "^4.18.0",
|
|
67
|
-
"@trpc/client": "10.
|
|
68
|
-
"@trpc/server": "10.
|
|
73
|
+
"@trpc/client": "10.19.0",
|
|
74
|
+
"@trpc/server": "10.19.0",
|
|
69
75
|
"@types/express": "^4.17.12",
|
|
70
76
|
"@types/node": "^18.7.20",
|
|
71
77
|
"@types/react": "^18.0.9",
|
|
@@ -81,5 +87,5 @@
|
|
|
81
87
|
"publishConfig": {
|
|
82
88
|
"access": "public"
|
|
83
89
|
},
|
|
84
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "bfc5b3af67f916d7090df3ea21383ce9912e4076"
|
|
85
91
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/server';
|
package/server/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/server');
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
createRecursiveProxy,
|
|
18
18
|
inferTransformedProcedureOutput,
|
|
19
19
|
} from '@trpc/server/shared';
|
|
20
|
-
import {
|
|
20
|
+
import { createSSGHelpers } from '../ssg/ssg';
|
|
21
|
+
import { CreateSSGHelpersOptions } from './types';
|
|
21
22
|
|
|
22
23
|
type DecorateProcedure<TProcedure extends AnyProcedure> = {
|
|
23
24
|
/**
|
|
@@ -63,12 +64,12 @@ type AnyDecoratedProcedure = DecorateProcedure<any>;
|
|
|
63
64
|
/**
|
|
64
65
|
* Create functions you can use for server-side rendering / static generation
|
|
65
66
|
*/
|
|
66
|
-
export function
|
|
67
|
+
export function createServerSideHelpers<TRouter extends AnyRouter>(
|
|
67
68
|
opts: CreateSSGHelpersOptions<TRouter>,
|
|
68
69
|
) {
|
|
69
70
|
const helpers = createSSGHelpers(opts);
|
|
70
71
|
|
|
71
|
-
type
|
|
72
|
+
type CreateServerSideHelpers = ProtectedIntersection<
|
|
72
73
|
{
|
|
73
74
|
queryClient: QueryClient;
|
|
74
75
|
dehydrate: (opts?: DehydrateOptions) => DehydratedState;
|
|
@@ -76,7 +77,7 @@ export function createProxySSGHelpers<TRouter extends AnyRouter>(
|
|
|
76
77
|
DecoratedProcedureSSGRecord<TRouter>
|
|
77
78
|
>;
|
|
78
79
|
|
|
79
|
-
return createFlatProxy<
|
|
80
|
+
return createFlatProxy<CreateServerSideHelpers>((key) => {
|
|
80
81
|
if (key === 'queryClient') {
|
|
81
82
|
return helpers.queryClient;
|
|
82
83
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AnyRouter,
|
|
3
|
+
ClientDataTransformerOptions,
|
|
4
|
+
inferRouterContext,
|
|
5
|
+
} from '@trpc/server';
|
|
6
|
+
import { CreateTRPCReactQueryClientConfig } from '../shared';
|
|
7
|
+
|
|
8
|
+
interface CreateSSGHelpersOptionsBase<TRouter extends AnyRouter> {
|
|
9
|
+
router: TRouter;
|
|
10
|
+
ctx: inferRouterContext<TRouter>;
|
|
11
|
+
transformer?: ClientDataTransformerOptions;
|
|
12
|
+
}
|
|
13
|
+
export type CreateSSGHelpersOptions<TRouter extends AnyRouter> =
|
|
14
|
+
CreateSSGHelpersOptionsBase<TRouter> & CreateTRPCReactQueryClientConfig;
|
|
@@ -242,7 +242,7 @@ export function createReactQueryUtilsProxy<
|
|
|
242
242
|
>;
|
|
243
243
|
|
|
244
244
|
return createFlatProxy<CreateReactUtilsProxyReturnType>((key) => {
|
|
245
|
-
const contextName = key as typeof contextProps[number];
|
|
245
|
+
const contextName = key as (typeof contextProps)[number];
|
|
246
246
|
if (contextName === 'client') {
|
|
247
247
|
return createTRPCClientProxy(context.client);
|
|
248
248
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export {
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated use `@trpc/react/server` instead
|
|
4
|
+
*/
|
|
5
|
+
type CreateSSGHelpersOptions,
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use `@trpc/react/server` instead
|
|
8
|
+
*/
|
|
9
|
+
type DecoratedProcedureSSGRecord,
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use `import { createServerSideHelpers } from "@trpc/react/server"`;
|
|
12
|
+
*/
|
|
13
|
+
createServerSideHelpers as createProxySSGHelpers,
|
|
14
|
+
} from '../server';
|
|
15
|
+
|
|
16
|
+
export { createSSGHelpers } from './ssg';
|
package/src/ssg/ssg.ts
CHANGED
|
@@ -6,26 +6,17 @@ import {
|
|
|
6
6
|
} from '@tanstack/react-query';
|
|
7
7
|
import {
|
|
8
8
|
AnyRouter,
|
|
9
|
-
ClientDataTransformerOptions,
|
|
10
9
|
callProcedure,
|
|
11
10
|
inferHandlerInput,
|
|
12
11
|
inferProcedureOutput,
|
|
13
|
-
inferRouterContext,
|
|
14
12
|
} from '@trpc/server';
|
|
15
13
|
import { getArrayQueryKey } from '../internals/getArrayQueryKey';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
interface CreateSSGHelpersOptionsBase<TRouter extends AnyRouter> {
|
|
19
|
-
router: TRouter;
|
|
20
|
-
ctx: inferRouterContext<TRouter>;
|
|
21
|
-
transformer?: ClientDataTransformerOptions;
|
|
22
|
-
}
|
|
23
|
-
export type CreateSSGHelpersOptions<TRouter extends AnyRouter> =
|
|
24
|
-
CreateSSGHelpersOptionsBase<TRouter> & CreateTRPCReactQueryClientConfig;
|
|
14
|
+
import { CreateSSGHelpersOptions } from '../server/types';
|
|
15
|
+
import { getQueryClient } from '../shared';
|
|
25
16
|
|
|
26
17
|
/**
|
|
27
18
|
* Create functions you can use for server-side rendering / static generation
|
|
28
|
-
* @deprecated use `
|
|
19
|
+
* @deprecated use `createServerSideHelpers` instead
|
|
29
20
|
*/
|
|
30
21
|
export function createSSGHelpers<TRouter extends AnyRouter>(
|
|
31
22
|
opts: CreateSSGHelpersOptions<TRouter>,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ssgProxy.d.ts","sourceRoot":"","sources":["../../src/ssg/ssgProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,MAAM,EACN,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,+BAA+B,EAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAoB,MAAM,OAAO,CAAC;AAElE,aAAK,iBAAiB,CAAC,UAAU,SAAS,YAAY,IAAI;IACxD;;OAEG;IACH,KAAK,CACH,GAAG,IAAI,EAAE,iBAAiB,CAAC,UAAU,CAAC,GACrC,OAAO,CAAC,+BAA+B,CAAC,UAAU,CAAC,CAAC,CAAC;IAExD;;OAEG;IACH,aAAa,CACX,GAAG,IAAI,EAAE,iBAAiB,CAAC,UAAU,CAAC,GACrC,OAAO,CAAC,YAAY,CAAC,+BAA+B,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAEtE;;OAEG;IACH,QAAQ,CAAC,GAAG,IAAI,EAAE,iBAAiB,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE;;OAEG;IACH,gBAAgB,CAAC,GAAG,IAAI,EAAE,iBAAiB,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzE,CAAC;AAEF;;GAEG;AACH,oBAAY,2BAA2B,CAAC,OAAO,SAAS,SAAS,IAAI;KAClE,IAAI,IAAI,MAAM,MAAM,CACnB,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACzB,SAAS,GAAG,iBAAiB,CAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GACjD,2BAA2B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,GAE5D,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAIF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC;iBAMrB,WAAW;uBACL,gBAAgB,KAAK,eAAe;yCAsC5D"}
|
package/src/ssg/index.ts
DELETED