@trpc/react-query 11.0.0-alpha-tmp-react-sideeffects-import.202 → 11.0.0-alpha-tmp-ahmed-rollup-v4.203
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/createTRPCQueryUtils.js +15 -0
- package/dist/createTRPCQueryUtils.mjs +13 -0
- package/dist/createTRPCReact.js +38 -0
- package/dist/createTRPCReact.mjs +35 -0
- package/dist/index.js +10 -64
- package/dist/index.mjs +3 -40
- package/dist/internals/context.d.ts +2 -2
- package/dist/internals/context.d.ts.map +1 -1
- package/dist/internals/context.js +14 -0
- package/dist/internals/context.mjs +11 -0
- package/dist/internals/getClientArgs.js +16 -0
- package/dist/internals/getClientArgs.mjs +14 -0
- package/dist/internals/getQueryKey.js +45 -0
- package/dist/internals/getQueryKey.mjs +42 -0
- package/dist/internals/useHookResult.js +13 -0
- package/dist/internals/useHookResult.mjs +11 -0
- package/dist/server/index.js +2 -102
- package/dist/server/index.mjs +1 -103
- package/dist/server/ssgProxy.js +106 -0
- package/dist/server/ssgProxy.mjs +104 -0
- package/dist/shared/hooks/createHooksInternal.d.ts.map +1 -1
- package/dist/{createHooksInternal-5d2fa367.js → shared/hooks/createHooksInternal.js} +33 -207
- package/dist/{createHooksInternal-e0b0564e.mjs → shared/hooks/createHooksInternal.mjs} +16 -166
- package/dist/shared/index.js +13 -15
- package/dist/shared/index.mjs +7 -7
- package/dist/shared/proxy/decorationProxy.js +31 -0
- package/dist/shared/proxy/decorationProxy.mjs +29 -0
- package/dist/shared/proxy/useQueriesProxy.js +25 -0
- package/dist/shared/proxy/useQueriesProxy.mjs +23 -0
- package/dist/shared/proxy/utilsProxy.js +89 -0
- package/dist/{utilsProxy-61a4601f.mjs → shared/proxy/utilsProxy.mjs} +3 -51
- package/dist/{queryClient-4d766c0c.mjs → shared/queryClient.mjs} +1 -1
- package/dist/utils/createUtilityFunctions.js +94 -0
- package/dist/utils/createUtilityFunctions.mjs +92 -0
- package/package.json +6 -6
- package/src/createTRPCReact.tsx +2 -2
- package/src/internals/context.tsx +2 -2
- package/src/internals/useHookResult.ts +2 -2
- package/src/shared/hooks/createHooksInternal.tsx +8 -10
- package/dist/createHooksInternal-4285c71a.js +0 -470
- package/dist/queryClient-1c8d7d8a.js +0 -8
- package/dist/utilsProxy-0b88c1e3.js +0 -161
- package/dist/utilsProxy-ff357a62.js +0 -128
- /package/dist/{queryClient-358a9a75.js → shared/queryClient.js} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('@trpc/core');
|
|
4
|
+
var utilsProxy = require('./shared/proxy/utilsProxy.js');
|
|
5
|
+
require('@tanstack/react-query');
|
|
6
|
+
require('@trpc/client');
|
|
7
|
+
require('react');
|
|
8
|
+
var createUtilityFunctions = require('./utils/createUtilityFunctions.js');
|
|
9
|
+
|
|
10
|
+
function createTRPCQueryUtils(opts) {
|
|
11
|
+
const utils = createUtilityFunctions.createUtilityFunctions(opts);
|
|
12
|
+
return utilsProxy.createQueryUtilsProxy(utils);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.createTRPCQueryUtils = createTRPCQueryUtils;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import '@trpc/core';
|
|
2
|
+
import { createQueryUtilsProxy } from './shared/proxy/utilsProxy.mjs';
|
|
3
|
+
import '@tanstack/react-query';
|
|
4
|
+
import '@trpc/client';
|
|
5
|
+
import 'react';
|
|
6
|
+
import { createUtilityFunctions } from './utils/createUtilityFunctions.mjs';
|
|
7
|
+
|
|
8
|
+
function createTRPCQueryUtils(opts) {
|
|
9
|
+
const utils = createUtilityFunctions(opts);
|
|
10
|
+
return createQueryUtilsProxy(utils);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { createTRPCQueryUtils };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@trpc/core');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var decorationProxy = require('./shared/proxy/decorationProxy.js');
|
|
6
|
+
var utilsProxy = require('./shared/proxy/utilsProxy.js');
|
|
7
|
+
var createHooksInternal$1 = require('./shared/hooks/createHooksInternal.js');
|
|
8
|
+
require('@tanstack/react-query');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/ function createHooksInternal(trpc) {
|
|
13
|
+
return core.createFlatProxy((key)=>{
|
|
14
|
+
if (key === 'useContext' || key === 'useUtils') {
|
|
15
|
+
return ()=>{
|
|
16
|
+
const context = trpc.useUtils();
|
|
17
|
+
// create a stable reference of the utils context
|
|
18
|
+
return React.useMemo(()=>{
|
|
19
|
+
return utilsProxy.createReactQueryUtils(context);
|
|
20
|
+
}, [
|
|
21
|
+
context
|
|
22
|
+
]);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (trpc.hasOwnProperty(key)) {
|
|
26
|
+
return trpc[key];
|
|
27
|
+
}
|
|
28
|
+
return decorationProxy.createReactDecoration(key, trpc);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function createTRPCReact(opts) {
|
|
32
|
+
const hooks = createHooksInternal$1.createRootHooks(opts);
|
|
33
|
+
const proxy = createHooksInternal(hooks);
|
|
34
|
+
return proxy;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.createHooksInternal = createHooksInternal;
|
|
38
|
+
exports.createTRPCReact = createTRPCReact;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createFlatProxy } from '@trpc/core';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { createReactDecoration } from './shared/proxy/decorationProxy.mjs';
|
|
4
|
+
import { createReactQueryUtils } from './shared/proxy/utilsProxy.mjs';
|
|
5
|
+
import { createRootHooks } from './shared/hooks/createHooksInternal.mjs';
|
|
6
|
+
import '@tanstack/react-query';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/ function createHooksInternal(trpc) {
|
|
11
|
+
return createFlatProxy((key)=>{
|
|
12
|
+
if (key === 'useContext' || key === 'useUtils') {
|
|
13
|
+
return ()=>{
|
|
14
|
+
const context = trpc.useUtils();
|
|
15
|
+
// create a stable reference of the utils context
|
|
16
|
+
return useMemo(()=>{
|
|
17
|
+
return createReactQueryUtils(context);
|
|
18
|
+
}, [
|
|
19
|
+
context
|
|
20
|
+
]);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (trpc.hasOwnProperty(key)) {
|
|
24
|
+
return trpc[key];
|
|
25
|
+
}
|
|
26
|
+
return createReactDecoration(key, trpc);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function createTRPCReact(opts) {
|
|
30
|
+
const hooks = createRootHooks(opts);
|
|
31
|
+
const proxy = createHooksInternal(hooks);
|
|
32
|
+
return proxy;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { createHooksInternal, createTRPCReact };
|
package/dist/index.js
CHANGED
|
@@ -1,72 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var client = require('@trpc/client');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var createHooksInternal$1 = require('./createHooksInternal-5d2fa367.js');
|
|
10
|
-
require('@tanstack/react-query');
|
|
11
|
-
|
|
12
|
-
function _interopNamespace(e) {
|
|
13
|
-
if (e && e.__esModule) return e;
|
|
14
|
-
var n = Object.create(null);
|
|
15
|
-
if (e) {
|
|
16
|
-
Object.keys(e).forEach(function (k) {
|
|
17
|
-
if (k !== 'default') {
|
|
18
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () { return e[k]; }
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
n["default"] = e;
|
|
27
|
-
return Object.freeze(n);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
4
|
+
var getQueryKey = require('./internals/getQueryKey.js');
|
|
5
|
+
var createTRPCReact = require('./createTRPCReact.js');
|
|
6
|
+
var createTRPCQueryUtils = require('./createTRPCQueryUtils.js');
|
|
31
7
|
|
|
32
|
-
/**
|
|
33
|
-
* @internal
|
|
34
|
-
*/ function createHooksInternal(trpc) {
|
|
35
|
-
return core.createFlatProxy((key)=>{
|
|
36
|
-
if (key === 'useContext' || key === 'useUtils') {
|
|
37
|
-
return ()=>{
|
|
38
|
-
const context = trpc.useUtils();
|
|
39
|
-
// create a stable reference of the utils context
|
|
40
|
-
return React__namespace.useMemo(()=>{
|
|
41
|
-
return utilsProxy.createReactQueryUtils(context);
|
|
42
|
-
}, [
|
|
43
|
-
context
|
|
44
|
-
]);
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
if (trpc.hasOwnProperty(key)) {
|
|
48
|
-
return trpc[key];
|
|
49
|
-
}
|
|
50
|
-
return createHooksInternal$1.createReactDecoration(key, trpc);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
function createTRPCReact(opts) {
|
|
54
|
-
const hooks = createHooksInternal$1.createRootHooks(opts);
|
|
55
|
-
const proxy = createHooksInternal(hooks);
|
|
56
|
-
return proxy;
|
|
57
|
-
}
|
|
58
8
|
|
|
59
|
-
function createTRPCQueryUtils(opts) {
|
|
60
|
-
const utils = createHooksInternal$1.createUtilityFunctions(opts);
|
|
61
|
-
return utilsProxy.createQueryUtilsProxy(utils);
|
|
62
|
-
}
|
|
63
9
|
|
|
64
|
-
exports.getQueryKey =
|
|
65
|
-
exports.
|
|
66
|
-
exports.
|
|
10
|
+
exports.getQueryKey = getQueryKey.getQueryKey;
|
|
11
|
+
exports.createTRPCReact = createTRPCReact.createTRPCReact;
|
|
12
|
+
exports.createTRPCQueryUtils = createTRPCQueryUtils.createTRPCQueryUtils;
|
|
67
13
|
Object.keys(client).forEach(function (k) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
14
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return client[k]; }
|
|
17
|
+
});
|
|
72
18
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,41 +1,4 @@
|
|
|
1
1
|
export * from '@trpc/client';
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
import { c as createRootHooks, a as createReactDecoration, b as createUtilityFunctions } from './createHooksInternal-e0b0564e.mjs';
|
|
7
|
-
import '@tanstack/react-query';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/ function createHooksInternal(trpc) {
|
|
12
|
-
return createFlatProxy((key)=>{
|
|
13
|
-
if (key === 'useContext' || key === 'useUtils') {
|
|
14
|
-
return ()=>{
|
|
15
|
-
const context = trpc.useUtils();
|
|
16
|
-
// create a stable reference of the utils context
|
|
17
|
-
return React.useMemo(()=>{
|
|
18
|
-
return createReactQueryUtils(context);
|
|
19
|
-
}, [
|
|
20
|
-
context
|
|
21
|
-
]);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
if (trpc.hasOwnProperty(key)) {
|
|
25
|
-
return trpc[key];
|
|
26
|
-
}
|
|
27
|
-
return createReactDecoration(key, trpc);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function createTRPCReact(opts) {
|
|
31
|
-
const hooks = createRootHooks(opts);
|
|
32
|
-
const proxy = createHooksInternal(hooks);
|
|
33
|
-
return proxy;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function createTRPCQueryUtils(opts) {
|
|
37
|
-
const utils = createUtilityFunctions(opts);
|
|
38
|
-
return createQueryUtilsProxy(utils);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export { createTRPCQueryUtils, createTRPCReact };
|
|
2
|
+
export { getQueryKey } from './internals/getQueryKey.mjs';
|
|
3
|
+
export { createTRPCReact } from './createTRPCReact.mjs';
|
|
4
|
+
export { createTRPCQueryUtils } from './createTRPCQueryUtils.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { CancelOptions, FetchInfiniteQueryOptions, FetchQueryOptions, InfiniteData, InvalidateOptions, InvalidateQueryFilters, QueryClient, QueryFilters, RefetchOptions, RefetchQueryFilters, ResetOptions, SetDataOptions, Updater } from '@tanstack/react-query';
|
|
2
3
|
import type { CreateTRPCClient, TRPCClientError, TRPCRequestOptions, TRPCUntypedClient } from '@trpc/client';
|
|
3
4
|
import type { AnyRouter, DistributiveOmit } from '@trpc/core';
|
|
4
|
-
import * as React from 'react';
|
|
5
5
|
import type { ExtractCursorType } from '../shared';
|
|
6
6
|
import type { TRPCQueryKey } from './getQueryKey';
|
|
7
7
|
export type TRPCFetchQueryOptions<TOutput, TError> = DistributiveOmit<FetchQueryOptions<TOutput, TError>, 'queryKey'> & TRPCRequestOptions;
|
|
@@ -111,5 +111,5 @@ export interface TRPCQueryUtils<TRouter extends AnyRouter> {
|
|
|
111
111
|
*/
|
|
112
112
|
getInfiniteQueryData: (queryKey: TRPCQueryKey) => InfiniteData<unknown> | undefined;
|
|
113
113
|
}
|
|
114
|
-
export declare const TRPCContext:
|
|
114
|
+
export declare const TRPCContext: import("react").Context<any>;
|
|
115
115
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/internals/context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,yBAAyB,EACzB,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,OAAO,EACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/internals/context.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,aAAa,EACb,yBAAyB,EACzB,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,OAAO,EACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,qBAAqB,CAAC,OAAO,EAAE,MAAM,IAAI,gBAAgB,CACnE,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,EAClC,UAAU,CACX,GACC,kBAAkB,CAAC;AAErB,MAAM,MAAM,6BAA6B,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,IAC/D,gBAAgB,CACd,yBAAyB,CACvB,OAAO,EACP,MAAM,EACN,OAAO,EACP,YAAY,EACZ,iBAAiB,CAAC,MAAM,CAAC,CAC1B,EACD,UAAU,GAAG,kBAAkB,CAChC,GACC,kBAAkB,GAAG;IACnB,aAAa,CAAC,EAAE,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AC7B,OAAO,CAAC,EAAE,cAAc,KACrB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;OAEG;IACH,WAAW,EAAE,CACX,QAAQ,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,aAAa,KACpB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;OAEG;IACH,YAAY,EAAE,CACZ,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAClC,OAAO,CAAC,EAAE,cAAc,KACrB,IAAI,CAAC;IAEV;;OAEG;IACH,YAAY,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,OAAO,CAAC;IAClD;;OAEG;IACH,oBAAoB,EAAE,CACpB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,CACd,YAAY,CAAC,OAAO,CAAC,GAAG,SAAS,EACjC,YAAY,CAAC,OAAO,CAAC,GAAG,SAAS,CAClC,EACD,OAAO,CAAC,EAAE,cAAc,KACrB,IAAI,CAAC;IAEV;;OAEG;IACH,oBAAoB,EAAE,CACpB,QAAQ,EAAE,YAAY,KACnB,YAAY,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;CACxC;AACD,eAAO,MAAM,WAAW,8BAA6B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
const contextProps = [
|
|
6
|
+
'client',
|
|
7
|
+
'ssrContext',
|
|
8
|
+
'ssrState',
|
|
9
|
+
'abortOnUnmount'
|
|
10
|
+
];
|
|
11
|
+
const TRPCContext = /*#__PURE__*/ React.createContext(null);
|
|
12
|
+
|
|
13
|
+
exports.TRPCContext = TRPCContext;
|
|
14
|
+
exports.contextProps = contextProps;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/ function getClientArgs(queryKey, opts, pageParam) {
|
|
6
|
+
const path = queryKey[0];
|
|
7
|
+
const input = queryKey[1]?.input;
|
|
8
|
+
if (pageParam) input.cursor = pageParam;
|
|
9
|
+
return [
|
|
10
|
+
path.join('.'),
|
|
11
|
+
input,
|
|
12
|
+
opts?.trpc
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.getClientArgs = getClientArgs;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/ function getClientArgs(queryKey, opts, pageParam) {
|
|
4
|
+
const path = queryKey[0];
|
|
5
|
+
const input = queryKey[1]?.input;
|
|
6
|
+
if (pageParam) input.cursor = pageParam;
|
|
7
|
+
return [
|
|
8
|
+
path.join('.'),
|
|
9
|
+
input,
|
|
10
|
+
opts?.trpc
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { getClientArgs };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* To allow easy interactions with groups of related queries, such as
|
|
5
|
+
* invalidating all queries of a router, we use an array as the path when
|
|
6
|
+
* storing in tanstack query.
|
|
7
|
+
**/ function getQueryKeyInternal(path, input, type) {
|
|
8
|
+
// Construct a query key that is easy to destructure and flexible for
|
|
9
|
+
// partial selecting etc.
|
|
10
|
+
// https://github.com/trpc/trpc/issues/3128
|
|
11
|
+
// some parts of the path may be dot-separated, split them up
|
|
12
|
+
const splitPath = path.flatMap((part)=>part.split('.'));
|
|
13
|
+
if (!input && (!type || type === 'any')) // for `utils.invalidate()` to match all queries (including vanilla react-query)
|
|
14
|
+
// we don't want nested array if path is empty, i.e. `[]` instead of `[[]]`
|
|
15
|
+
return splitPath.length ? [
|
|
16
|
+
splitPath
|
|
17
|
+
] : [];
|
|
18
|
+
return [
|
|
19
|
+
splitPath,
|
|
20
|
+
{
|
|
21
|
+
...typeof input !== 'undefined' && {
|
|
22
|
+
input: input
|
|
23
|
+
},
|
|
24
|
+
...type && type !== 'any' && {
|
|
25
|
+
type: type
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Method to extract the query key for a procedure
|
|
32
|
+
* @param procedureOrRouter - procedure or AnyRouter
|
|
33
|
+
* @param input - input to procedureOrRouter
|
|
34
|
+
* @param type - defaults to `any`
|
|
35
|
+
* @link https://trpc.io/docs/v11/getQueryKey
|
|
36
|
+
*/ function getQueryKey(..._params) {
|
|
37
|
+
const [procedureOrRouter, input, type] = _params;
|
|
38
|
+
// @ts-expect-error - we don't expose _def on the type layer
|
|
39
|
+
const path = procedureOrRouter._def().path;
|
|
40
|
+
const queryKey = getQueryKeyInternal(path, input, type ?? 'any');
|
|
41
|
+
return queryKey;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.getQueryKey = getQueryKey;
|
|
45
|
+
exports.getQueryKeyInternal = getQueryKeyInternal;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* To allow easy interactions with groups of related queries, such as
|
|
3
|
+
* invalidating all queries of a router, we use an array as the path when
|
|
4
|
+
* storing in tanstack query.
|
|
5
|
+
**/ function getQueryKeyInternal(path, input, type) {
|
|
6
|
+
// Construct a query key that is easy to destructure and flexible for
|
|
7
|
+
// partial selecting etc.
|
|
8
|
+
// https://github.com/trpc/trpc/issues/3128
|
|
9
|
+
// some parts of the path may be dot-separated, split them up
|
|
10
|
+
const splitPath = path.flatMap((part)=>part.split('.'));
|
|
11
|
+
if (!input && (!type || type === 'any')) // for `utils.invalidate()` to match all queries (including vanilla react-query)
|
|
12
|
+
// we don't want nested array if path is empty, i.e. `[]` instead of `[[]]`
|
|
13
|
+
return splitPath.length ? [
|
|
14
|
+
splitPath
|
|
15
|
+
] : [];
|
|
16
|
+
return [
|
|
17
|
+
splitPath,
|
|
18
|
+
{
|
|
19
|
+
...typeof input !== 'undefined' && {
|
|
20
|
+
input: input
|
|
21
|
+
},
|
|
22
|
+
...type && type !== 'any' && {
|
|
23
|
+
type: type
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Method to extract the query key for a procedure
|
|
30
|
+
* @param procedureOrRouter - procedure or AnyRouter
|
|
31
|
+
* @param input - input to procedureOrRouter
|
|
32
|
+
* @param type - defaults to `any`
|
|
33
|
+
* @link https://trpc.io/docs/v11/getQueryKey
|
|
34
|
+
*/ function getQueryKey(..._params) {
|
|
35
|
+
const [procedureOrRouter, input, type] = _params;
|
|
36
|
+
// @ts-expect-error - we don't expose _def on the type layer
|
|
37
|
+
const path = procedureOrRouter._def().path;
|
|
38
|
+
const queryKey = getQueryKeyInternal(path, input, type ?? 'any');
|
|
39
|
+
return queryKey;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { getQueryKey, getQueryKeyInternal };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Makes a stable reference of the `trpc` prop
|
|
7
|
+
*/ function useHookResult(value) {
|
|
8
|
+
const ref = React.useRef(value);
|
|
9
|
+
ref.current.path = value.path;
|
|
10
|
+
return ref.current;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.useHookResult = useHookResult;
|
package/dist/server/index.js
CHANGED
|
@@ -1,107 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var ssgProxy = require('./ssgProxy.js');
|
|
4
4
|
|
|
5
|
-
var reactQuery = require('@tanstack/react-query');
|
|
6
|
-
var client = require('@trpc/client');
|
|
7
|
-
var core = require('@trpc/core');
|
|
8
|
-
var utilsProxy = require('../utilsProxy-0b88c1e3.js');
|
|
9
|
-
require('react');
|
|
10
|
-
var queryClient = require('../queryClient-358a9a75.js');
|
|
11
5
|
|
|
12
|
-
/**
|
|
13
|
-
* Create functions you can use for server-side rendering / static generation
|
|
14
|
-
* @link https://trpc.io/docs/v11/client/nextjs/server-side-helpers
|
|
15
|
-
*/ function createServerSideHelpers(opts) {
|
|
16
|
-
const queryClient$1 = queryClient.getQueryClient(opts);
|
|
17
|
-
const resolvedOpts = (()=>{
|
|
18
|
-
if ('router' in opts) {
|
|
19
|
-
const { transformer , ctx , router } = opts;
|
|
20
|
-
return {
|
|
21
|
-
serialize: transformer ? ('input' in transformer ? transformer.input : transformer).serialize : (obj)=>obj,
|
|
22
|
-
query: (queryOpts)=>{
|
|
23
|
-
return core.callProcedure({
|
|
24
|
-
procedures: router._def.procedures,
|
|
25
|
-
path: queryOpts.path,
|
|
26
|
-
getRawInput: async ()=>queryOpts.input,
|
|
27
|
-
ctx,
|
|
28
|
-
type: 'query'
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const { client: client$1 } = opts;
|
|
34
|
-
const untypedClient = client$1 instanceof client.TRPCUntypedClient ? client$1 : client.getUntypedClient(client$1);
|
|
35
|
-
return {
|
|
36
|
-
query: (queryOpts)=>untypedClient.query(queryOpts.path, queryOpts.input),
|
|
37
|
-
serialize: (obj)=>untypedClient.runtime.transformer.serialize(obj)
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
function _dehydrate(opts = {
|
|
41
|
-
shouldDehydrateQuery () {
|
|
42
|
-
// makes sure to serialize errors
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
}) {
|
|
46
|
-
const before = reactQuery.dehydrate(queryClient$1, opts);
|
|
47
|
-
const after = resolvedOpts.serialize(before);
|
|
48
|
-
return after;
|
|
49
|
-
}
|
|
50
|
-
return core.createFlatProxy((key)=>{
|
|
51
|
-
if (key === 'queryClient') return queryClient$1;
|
|
52
|
-
if (key === 'dehydrate') return _dehydrate;
|
|
53
|
-
return core.createRecursiveProxy((opts)=>{
|
|
54
|
-
const args = opts.args;
|
|
55
|
-
const input = args[0];
|
|
56
|
-
const arrayPath = [
|
|
57
|
-
key,
|
|
58
|
-
...opts.path
|
|
59
|
-
];
|
|
60
|
-
const utilName = arrayPath.pop();
|
|
61
|
-
const queryFn = ()=>resolvedOpts.query({
|
|
62
|
-
path: arrayPath.join('.'),
|
|
63
|
-
input
|
|
64
|
-
});
|
|
65
|
-
const queryKey = utilsProxy.getQueryKeyInternal(arrayPath, input, utilsProxy.getQueryType(utilName));
|
|
66
|
-
const helperMap = {
|
|
67
|
-
fetch: ()=>{
|
|
68
|
-
const args1 = args[1];
|
|
69
|
-
return queryClient$1.fetchQuery({
|
|
70
|
-
...args1,
|
|
71
|
-
queryKey,
|
|
72
|
-
queryFn
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
fetchInfinite: ()=>{
|
|
76
|
-
const args1 = args[1];
|
|
77
|
-
return queryClient$1.fetchInfiniteQuery({
|
|
78
|
-
...args1,
|
|
79
|
-
queryKey,
|
|
80
|
-
queryFn,
|
|
81
|
-
initialPageParam: args1?.initialCursor ?? null
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
prefetch: ()=>{
|
|
85
|
-
const args1 = args[1];
|
|
86
|
-
return queryClient$1.prefetchQuery({
|
|
87
|
-
...args1,
|
|
88
|
-
queryKey,
|
|
89
|
-
queryFn
|
|
90
|
-
});
|
|
91
|
-
},
|
|
92
|
-
prefetchInfinite: ()=>{
|
|
93
|
-
const args1 = args[1];
|
|
94
|
-
return queryClient$1.prefetchInfiniteQuery({
|
|
95
|
-
...args1,
|
|
96
|
-
queryKey,
|
|
97
|
-
queryFn,
|
|
98
|
-
initialPageParam: args1?.initialCursor ?? null
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
return helperMap[utilName]();
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
6
|
|
|
107
|
-
exports.createServerSideHelpers = createServerSideHelpers;
|
|
7
|
+
exports.createServerSideHelpers = ssgProxy.createServerSideHelpers;
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,103 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { TRPCUntypedClient, getUntypedClient } from '@trpc/client';
|
|
3
|
-
import { callProcedure, createFlatProxy, createRecursiveProxy } from '@trpc/core';
|
|
4
|
-
import { b as getQueryKeyInternal, d as getQueryType } from '../utilsProxy-61a4601f.mjs';
|
|
5
|
-
import 'react';
|
|
6
|
-
import { g as getQueryClient } from '../queryClient-4d766c0c.mjs';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Create functions you can use for server-side rendering / static generation
|
|
10
|
-
* @link https://trpc.io/docs/v11/client/nextjs/server-side-helpers
|
|
11
|
-
*/ function createServerSideHelpers(opts) {
|
|
12
|
-
const queryClient = getQueryClient(opts);
|
|
13
|
-
const resolvedOpts = (()=>{
|
|
14
|
-
if ('router' in opts) {
|
|
15
|
-
const { transformer , ctx , router } = opts;
|
|
16
|
-
return {
|
|
17
|
-
serialize: transformer ? ('input' in transformer ? transformer.input : transformer).serialize : (obj)=>obj,
|
|
18
|
-
query: (queryOpts)=>{
|
|
19
|
-
return callProcedure({
|
|
20
|
-
procedures: router._def.procedures,
|
|
21
|
-
path: queryOpts.path,
|
|
22
|
-
getRawInput: async ()=>queryOpts.input,
|
|
23
|
-
ctx,
|
|
24
|
-
type: 'query'
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const { client } = opts;
|
|
30
|
-
const untypedClient = client instanceof TRPCUntypedClient ? client : getUntypedClient(client);
|
|
31
|
-
return {
|
|
32
|
-
query: (queryOpts)=>untypedClient.query(queryOpts.path, queryOpts.input),
|
|
33
|
-
serialize: (obj)=>untypedClient.runtime.transformer.serialize(obj)
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
function _dehydrate(opts = {
|
|
37
|
-
shouldDehydrateQuery () {
|
|
38
|
-
// makes sure to serialize errors
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
}) {
|
|
42
|
-
const before = dehydrate(queryClient, opts);
|
|
43
|
-
const after = resolvedOpts.serialize(before);
|
|
44
|
-
return after;
|
|
45
|
-
}
|
|
46
|
-
return createFlatProxy((key)=>{
|
|
47
|
-
if (key === 'queryClient') return queryClient;
|
|
48
|
-
if (key === 'dehydrate') return _dehydrate;
|
|
49
|
-
return createRecursiveProxy((opts)=>{
|
|
50
|
-
const args = opts.args;
|
|
51
|
-
const input = args[0];
|
|
52
|
-
const arrayPath = [
|
|
53
|
-
key,
|
|
54
|
-
...opts.path
|
|
55
|
-
];
|
|
56
|
-
const utilName = arrayPath.pop();
|
|
57
|
-
const queryFn = ()=>resolvedOpts.query({
|
|
58
|
-
path: arrayPath.join('.'),
|
|
59
|
-
input
|
|
60
|
-
});
|
|
61
|
-
const queryKey = getQueryKeyInternal(arrayPath, input, getQueryType(utilName));
|
|
62
|
-
const helperMap = {
|
|
63
|
-
fetch: ()=>{
|
|
64
|
-
const args1 = args[1];
|
|
65
|
-
return queryClient.fetchQuery({
|
|
66
|
-
...args1,
|
|
67
|
-
queryKey,
|
|
68
|
-
queryFn
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
fetchInfinite: ()=>{
|
|
72
|
-
const args1 = args[1];
|
|
73
|
-
return queryClient.fetchInfiniteQuery({
|
|
74
|
-
...args1,
|
|
75
|
-
queryKey,
|
|
76
|
-
queryFn,
|
|
77
|
-
initialPageParam: args1?.initialCursor ?? null
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
prefetch: ()=>{
|
|
81
|
-
const args1 = args[1];
|
|
82
|
-
return queryClient.prefetchQuery({
|
|
83
|
-
...args1,
|
|
84
|
-
queryKey,
|
|
85
|
-
queryFn
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
prefetchInfinite: ()=>{
|
|
89
|
-
const args1 = args[1];
|
|
90
|
-
return queryClient.prefetchInfiniteQuery({
|
|
91
|
-
...args1,
|
|
92
|
-
queryKey,
|
|
93
|
-
queryFn,
|
|
94
|
-
initialPageParam: args1?.initialCursor ?? null
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
return helperMap[utilName]();
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export { createServerSideHelpers };
|
|
1
|
+
export { createServerSideHelpers } from './ssgProxy.mjs';
|