@trpc/next 11.1.2 → 11.1.3-alpha-tmp-tsdown.23

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.
Files changed (80) hide show
  1. package/app-dir/client/package.json +1 -0
  2. package/app-dir/links/nextCache/package.json +1 -0
  3. package/app-dir/links/nextHttp/package.json +1 -0
  4. package/app-dir/server/package.json +1 -0
  5. package/dist/_virtual/rolldown_runtime.js +30 -0
  6. package/dist/app-dir/client.d.mts +13 -0
  7. package/dist/app-dir/client.d.mts.map +1 -0
  8. package/dist/app-dir/client.d.ts +12 -5
  9. package/dist/app-dir/client.d.ts.map +1 -1
  10. package/dist/app-dir/client.js +25 -43
  11. package/dist/app-dir/client.mjs +24 -40
  12. package/dist/app-dir/client.mjs.map +1 -0
  13. package/dist/app-dir/create-action-hook.d.mts +47 -0
  14. package/dist/app-dir/create-action-hook.d.mts.map +1 -0
  15. package/dist/app-dir/create-action-hook.d.ts +33 -36
  16. package/dist/app-dir/create-action-hook.d.ts.map +1 -1
  17. package/dist/app-dir/create-action-hook.js +85 -101
  18. package/dist/app-dir/create-action-hook.mjs +84 -98
  19. package/dist/app-dir/create-action-hook.mjs.map +1 -0
  20. package/dist/app-dir/links/nextCache.d.mts +16 -0
  21. package/dist/app-dir/links/nextCache.d.mts.map +1 -0
  22. package/dist/app-dir/links/nextCache.d.ts +13 -9
  23. package/dist/app-dir/links/nextCache.d.ts.map +1 -1
  24. package/dist/app-dir/links/nextCache.js +44 -58
  25. package/dist/app-dir/links/nextCache.mjs +43 -55
  26. package/dist/app-dir/links/nextCache.mjs.map +1 -0
  27. package/dist/app-dir/links/nextHttp.d.mts +19 -0
  28. package/dist/app-dir/links/nextHttp.d.mts.map +1 -0
  29. package/dist/app-dir/links/nextHttp.d.ts +12 -8
  30. package/dist/app-dir/links/nextHttp.d.ts.map +1 -1
  31. package/dist/app-dir/links/nextHttp.js +31 -35
  32. package/dist/app-dir/links/nextHttp.mjs +30 -32
  33. package/dist/app-dir/links/nextHttp.mjs.map +1 -0
  34. package/dist/app-dir/server.d.mts +36 -0
  35. package/dist/app-dir/server.d.mts.map +1 -0
  36. package/dist/app-dir/server.d.ts +30 -24
  37. package/dist/app-dir/server.d.ts.map +1 -1
  38. package/dist/app-dir/server.js +86 -112
  39. package/dist/app-dir/server.mjs +85 -109
  40. package/dist/app-dir/server.mjs.map +1 -0
  41. package/dist/app-dir/shared.d.mts +37 -0
  42. package/dist/app-dir/shared.d.mts.map +1 -0
  43. package/dist/app-dir/shared.d.ts +21 -39
  44. package/dist/app-dir/shared.d.ts.map +1 -1
  45. package/dist/app-dir/shared.js +12 -13
  46. package/dist/app-dir/shared.mjs +11 -10
  47. package/dist/app-dir/shared.mjs.map +1 -0
  48. package/dist/app-dir/types.d.mts +33 -0
  49. package/dist/app-dir/types.d.mts.map +1 -0
  50. package/dist/app-dir/types.d.ts +27 -25
  51. package/dist/app-dir/types.d.ts.map +1 -1
  52. package/dist/createTRPCNext.d.mts +38 -0
  53. package/dist/createTRPCNext.d.mts.map +1 -0
  54. package/dist/createTRPCNext.d.ts +30 -21
  55. package/dist/createTRPCNext.d.ts.map +1 -1
  56. package/dist/createTRPCNext.js +23 -35
  57. package/dist/createTRPCNext.mjs +22 -32
  58. package/dist/createTRPCNext.mjs.map +1 -0
  59. package/dist/index.d.mts +3 -0
  60. package/dist/index.d.ts +3 -3
  61. package/dist/index.js +4 -8
  62. package/dist/index.mjs +4 -2
  63. package/dist/ssrPrepass.d.mts +10 -0
  64. package/dist/ssrPrepass.d.mts.map +1 -0
  65. package/dist/ssrPrepass.d.ts +9 -2
  66. package/dist/ssrPrepass.d.ts.map +1 -1
  67. package/dist/ssrPrepass.js +99 -134
  68. package/dist/ssrPrepass.mjs +98 -131
  69. package/dist/ssrPrepass.mjs.map +1 -0
  70. package/dist/withTRPC.d.mts +55 -0
  71. package/dist/withTRPC.d.mts.map +1 -0
  72. package/dist/withTRPC.d.ts +47 -46
  73. package/dist/withTRPC.d.ts.map +1 -1
  74. package/dist/withTRPC.js +69 -82
  75. package/dist/withTRPC.mjs +68 -79
  76. package/dist/withTRPC.mjs.map +1 -0
  77. package/package.json +63 -33
  78. package/src/withTRPC.tsx +1 -2
  79. package/ssrPrepass/package.json +1 -0
  80. package/dist/index.d.ts.map +0 -1
@@ -1,118 +1,94 @@
1
- import { createTRPCUntypedClient, clientCallTypeToProcedureType } from '@trpc/client';
2
- import { rethrowNextErrors } from '@trpc/server/adapters/next-app-dir';
3
- import { createRecursiveProxy, formDataToObject, TRPCError, transformTRPCResponse, getTRPCErrorFromUnknown, getErrorShape } from '@trpc/server/unstable-core-do-not-import';
4
- import { revalidateTag } from 'next/cache';
5
- import { cache } from 'react';
6
- import { generateCacheTag, isFormData } from './shared.mjs';
1
+ import { generateCacheTag, isFormData } from "./shared.mjs";
2
+ import { cache } from "react";
3
+ import { TRPCError, createRecursiveProxy, formDataToObject, getErrorShape, getTRPCErrorFromUnknown, transformTRPCResponse } from "@trpc/server/unstable-core-do-not-import";
4
+ import { clientCallTypeToProcedureType, createTRPCUntypedClient } from "@trpc/client";
5
+ import { rethrowNextErrors } from "@trpc/server/adapters/next-app-dir";
6
+ import { revalidateTag } from "next/cache";
7
7
 
8
- /// <reference types="next" />
9
- // ts-prune-ignore-next
8
+ //#region src/app-dir/server.ts
10
9
  function experimental_createTRPCNextAppDirServer(opts) {
11
- const getClient = cache(()=>{
12
- const config = opts.config();
13
- return createTRPCUntypedClient(config);
14
- });
15
- return createRecursiveProxy((callOpts)=>{
16
- // lazily initialize client
17
- const client = getClient();
18
- const pathCopy = [
19
- ...callOpts.path
20
- ];
21
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22
- const action = pathCopy.pop();
23
- const procedurePath = pathCopy.join('.');
24
- const procedureType = clientCallTypeToProcedureType(action);
25
- const cacheTag = generateCacheTag(procedurePath, callOpts.args[0]);
26
- if (action === 'revalidate') {
27
- revalidateTag(cacheTag);
28
- return;
29
- }
30
- return client[procedureType](procedurePath, ...callOpts.args);
31
- });
10
+ const getClient = cache(() => {
11
+ const config = opts.config();
12
+ return createTRPCUntypedClient(config);
13
+ });
14
+ return createRecursiveProxy((callOpts) => {
15
+ const client = getClient();
16
+ const pathCopy = [...callOpts.path];
17
+ const action = pathCopy.pop();
18
+ const procedurePath = pathCopy.join(".");
19
+ const procedureType = clientCallTypeToProcedureType(action);
20
+ const cacheTag = generateCacheTag(procedurePath, callOpts.args[0]);
21
+ if (action === "revalidate") {
22
+ revalidateTag(cacheTag);
23
+ return;
24
+ }
25
+ return client[procedureType](procedurePath, ...callOpts.args);
26
+ });
32
27
  }
33
28
  function experimental_createServerActionHandler(t, opts) {
34
- const config = t._config;
35
- const { normalizeFormData = true, createContext, rethrowNextErrors: shouldRethrowNextErrors = true } = opts;
36
- const transformer = config.transformer;
37
- // TODO allow this to take a `TRouter` in addition to a `AnyProcedure`
38
- return function createServerAction(proc) {
39
- return async function actionHandler(rawInput) {
40
- let ctx = undefined;
41
- try {
42
- ctx = await createContext?.() ?? {};
43
- if (normalizeFormData && isFormData(rawInput)) {
44
- // Normalizes FormData so we can use `z.object({})` etc on the server
45
- try {
46
- rawInput = formDataToObject(rawInput);
47
- } catch {
48
- throw new TRPCError({
49
- code: 'INTERNAL_SERVER_ERROR',
50
- message: 'Failed to convert FormData to an object'
51
- });
52
- }
53
- } else if (rawInput && !isFormData(rawInput)) {
54
- rawInput = transformer.input.deserialize(rawInput);
55
- }
56
- const data = proc._def.experimental_caller ? await proc(rawInput) : await proc({
57
- input: undefined,
58
- ctx,
59
- path: '',
60
- getRawInput: async ()=>rawInput,
61
- type: proc._def.type,
62
- // is it possible to get the AbortSignal from the request?
63
- signal: undefined
64
- });
65
- const transformedJSON = transformTRPCResponse(config, {
66
- result: {
67
- data
68
- }
69
- });
70
- return transformedJSON;
71
- } catch (cause) {
72
- const error = getTRPCErrorFromUnknown(cause);
73
- opts.onError?.({
74
- ctx,
75
- error,
76
- input: rawInput,
77
- path: '',
78
- type: proc._def.type
79
- });
80
- if (shouldRethrowNextErrors) {
81
- rethrowNextErrors(error);
82
- }
83
- const shape = getErrorShape({
84
- config,
85
- ctx,
86
- error,
87
- input: rawInput,
88
- path: '',
89
- type: proc._def.type
90
- });
91
- return transformTRPCResponse(t._config, {
92
- error: shape
93
- });
94
- }
95
- };
96
- };
29
+ const config = t._config;
30
+ const { normalizeFormData = true, createContext, rethrowNextErrors: shouldRethrowNextErrors = true } = opts;
31
+ const transformer = config.transformer;
32
+ return function createServerAction(proc) {
33
+ return async function actionHandler(rawInput) {
34
+ let ctx = void 0;
35
+ try {
36
+ ctx = await createContext?.() ?? {};
37
+ if (normalizeFormData && isFormData(rawInput)) try {
38
+ rawInput = formDataToObject(rawInput);
39
+ } catch {
40
+ throw new TRPCError({
41
+ code: "INTERNAL_SERVER_ERROR",
42
+ message: "Failed to convert FormData to an object"
43
+ });
44
+ }
45
+ else if (rawInput && !isFormData(rawInput)) rawInput = transformer.input.deserialize(rawInput);
46
+ const data = proc._def.experimental_caller ? await proc(rawInput) : await proc({
47
+ input: void 0,
48
+ ctx,
49
+ path: "",
50
+ getRawInput: async () => rawInput,
51
+ type: proc._def.type,
52
+ signal: void 0
53
+ });
54
+ const transformedJSON = transformTRPCResponse(config, { result: { data } });
55
+ return transformedJSON;
56
+ } catch (cause) {
57
+ const error = getTRPCErrorFromUnknown(cause);
58
+ opts.onError?.({
59
+ ctx,
60
+ error,
61
+ input: rawInput,
62
+ path: "",
63
+ type: proc._def.type
64
+ });
65
+ if (shouldRethrowNextErrors) rethrowNextErrors(error);
66
+ const shape = getErrorShape({
67
+ config,
68
+ ctx,
69
+ error,
70
+ input: rawInput,
71
+ path: "",
72
+ type: proc._def.type
73
+ });
74
+ return transformTRPCResponse(t._config, { error: shape });
75
+ }
76
+ };
77
+ };
97
78
  }
98
- // ts-prune-ignore-next
99
79
  async function experimental_revalidateEndpoint(req) {
100
- const { cacheTag } = await req.json();
101
- if (typeof cacheTag !== 'string') {
102
- return new Response(JSON.stringify({
103
- revalidated: false,
104
- error: 'cacheTag must be a string'
105
- }), {
106
- status: 400
107
- });
108
- }
109
- revalidateTag(cacheTag);
110
- return new Response(JSON.stringify({
111
- revalidated: true,
112
- now: Date.now()
113
- }), {
114
- status: 200
115
- });
80
+ const { cacheTag } = await req.json();
81
+ if (typeof cacheTag !== "string") return new Response(JSON.stringify({
82
+ revalidated: false,
83
+ error: "cacheTag must be a string"
84
+ }), { status: 400 });
85
+ revalidateTag(cacheTag);
86
+ return new Response(JSON.stringify({
87
+ revalidated: true,
88
+ now: Date.now()
89
+ }), { status: 200 });
116
90
  }
117
91
 
92
+ //#endregion
118
93
  export { experimental_createServerActionHandler, experimental_createTRPCNextAppDirServer, experimental_revalidateEndpoint };
94
+ //# sourceMappingURL=server.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.mjs","names":["opts: CreateTRPCNextAppRouterOptions<TRouter>","t: TInstance","opts: CreateContextCallback<\n TInstance['_config']['$types']['ctx'],\n () => MaybePromise<TInstance['_config']['$types']['ctx']>\n > & {\n /**\n * Transform form data to a `Record` before passing it to the procedure\n * @default true\n */\n normalizeFormData?: boolean;\n /**\n * Called when an error occurs in the handler\n */\n onError?: (\n opts: ErrorHandlerOptions<TInstance['_config']['$types']['ctx']>,\n ) => void;\n\n /**\n * Rethrow errors that should be handled by Next.js\n * @default true\n */\n rethrowNextErrors?: boolean;\n }","proc: TProc","rawInput: FormData | inferProcedureInput<TProc>","ctx: TInstance['_config']['$types']['ctx'] | undefined","req: Request"],"sources":["../../src/app-dir/server.ts"],"sourcesContent":["/// <reference types=\"next\" />\nimport {\n clientCallTypeToProcedureType,\n createTRPCUntypedClient,\n} from '@trpc/client';\nimport type { CreateContextCallback } from '@trpc/server';\nimport { rethrowNextErrors } from '@trpc/server/adapters/next-app-dir';\nimport type {\n AnyProcedure,\n AnyRootTypes,\n AnyRouter,\n ErrorHandlerOptions,\n inferClientTypes,\n inferProcedureInput,\n MaybePromise,\n RootConfig,\n Simplify,\n TRPCResponse,\n} from '@trpc/server/unstable-core-do-not-import';\nimport {\n createRecursiveProxy,\n formDataToObject,\n getErrorShape,\n getTRPCErrorFromUnknown,\n transformTRPCResponse,\n TRPCError,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { revalidateTag } from 'next/cache';\nimport { cache } from 'react';\nimport type {\n ActionHandlerDef,\n CreateTRPCNextAppRouterOptions,\n inferActionDef,\n} from './shared';\nimport { generateCacheTag, isFormData } from './shared';\nimport type { NextAppDirDecorateRouterRecord } from './types';\n\nexport type { ActionHandlerDef };\n\n// ts-prune-ignore-next\nexport function experimental_createTRPCNextAppDirServer<\n TRouter extends AnyRouter,\n>(opts: CreateTRPCNextAppRouterOptions<TRouter>) {\n const getClient = cache(() => {\n const config = opts.config();\n return createTRPCUntypedClient(config);\n });\n\n return createRecursiveProxy<\n NextAppDirDecorateRouterRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >\n >((callOpts) => {\n // lazily initialize client\n const client = getClient();\n\n const pathCopy = [...callOpts.path];\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const action = pathCopy.pop()!;\n const procedurePath = pathCopy.join('.');\n const procedureType = clientCallTypeToProcedureType(action);\n const cacheTag = generateCacheTag(procedurePath, callOpts.args[0]);\n\n if (action === 'revalidate') {\n revalidateTag(cacheTag);\n return;\n }\n\n return (client[procedureType] as any)(procedurePath, ...callOpts.args);\n });\n}\n\n/**\n * @internal\n */\nexport type TRPCActionHandler<TDef extends ActionHandlerDef> = (\n input: FormData | TDef['input'],\n) => Promise<TRPCResponse<TDef['output'], TDef['errorShape']>>;\n\nexport function experimental_createServerActionHandler<\n TInstance extends {\n _config: RootConfig<AnyRootTypes>;\n },\n>(\n t: TInstance,\n opts: CreateContextCallback<\n TInstance['_config']['$types']['ctx'],\n () => MaybePromise<TInstance['_config']['$types']['ctx']>\n > & {\n /**\n * Transform form data to a `Record` before passing it to the procedure\n * @default true\n */\n normalizeFormData?: boolean;\n /**\n * Called when an error occurs in the handler\n */\n onError?: (\n opts: ErrorHandlerOptions<TInstance['_config']['$types']['ctx']>,\n ) => void;\n\n /**\n * Rethrow errors that should be handled by Next.js\n * @default true\n */\n rethrowNextErrors?: boolean;\n },\n) {\n const config = t._config;\n const {\n normalizeFormData = true,\n createContext,\n rethrowNextErrors: shouldRethrowNextErrors = true,\n } = opts;\n\n const transformer = config.transformer;\n\n // TODO allow this to take a `TRouter` in addition to a `AnyProcedure`\n return function createServerAction<TProc extends AnyProcedure>(\n proc: TProc,\n ): TRPCActionHandler<\n Simplify<inferActionDef<inferClientTypes<TInstance>, TProc>>\n > {\n return async function actionHandler(\n rawInput: FormData | inferProcedureInput<TProc>,\n ) {\n let ctx: TInstance['_config']['$types']['ctx'] | undefined = undefined;\n try {\n ctx = (await createContext?.()) ?? {};\n if (normalizeFormData && isFormData(rawInput)) {\n // Normalizes FormData so we can use `z.object({})` etc on the server\n try {\n rawInput = formDataToObject(rawInput);\n } catch {\n throw new TRPCError({\n code: 'INTERNAL_SERVER_ERROR',\n message: 'Failed to convert FormData to an object',\n });\n }\n } else if (rawInput && !isFormData(rawInput)) {\n rawInput = transformer.input.deserialize(rawInput);\n }\n\n const data = proc._def.experimental_caller\n ? await proc(rawInput as any)\n : await proc({\n input: undefined,\n ctx,\n path: '',\n getRawInput: async () => rawInput,\n type: proc._def.type,\n // is it possible to get the AbortSignal from the request?\n signal: undefined,\n });\n\n const transformedJSON = transformTRPCResponse(config, {\n result: {\n data,\n },\n });\n return transformedJSON;\n } catch (cause) {\n const error = getTRPCErrorFromUnknown(cause);\n\n opts.onError?.({\n ctx,\n error,\n input: rawInput,\n path: '',\n type: proc._def.type,\n });\n\n if (shouldRethrowNextErrors) {\n rethrowNextErrors(error);\n }\n\n const shape = getErrorShape({\n config,\n ctx,\n error,\n input: rawInput,\n path: '',\n type: proc._def.type,\n });\n\n return transformTRPCResponse(t._config, {\n error: shape,\n });\n }\n } as TRPCActionHandler<\n inferActionDef<TInstance['_config']['$types'], TProc>\n >;\n };\n}\n\n// ts-prune-ignore-next\nexport async function experimental_revalidateEndpoint(req: Request) {\n const { cacheTag } = await req.json();\n\n if (typeof cacheTag !== 'string') {\n return new Response(\n JSON.stringify({\n revalidated: false,\n error: 'cacheTag must be a string',\n }),\n { status: 400 },\n );\n }\n\n revalidateTag(cacheTag);\n return new Response(JSON.stringify({ revalidated: true, now: Date.now() }), {\n status: 200,\n });\n}\n"],"mappings":";;;;;;;;AAwCA,SAAgB,wCAEdA,MAA+C;CAC/C,MAAM,YAAY,MAAM,MAAM;EAC5B,MAAM,SAAS,KAAK,QAAQ;AAC5B,SAAO,wBAAwB,OAAO;CACvC,EAAC;AAEF,QAAO,qBAKL,CAAC,aAAa;EAEd,MAAM,SAAS,WAAW;EAE1B,MAAM,WAAW,CAAC,GAAG,SAAS,IAAK;EAEnC,MAAM,SAAS,SAAS,KAAK;EAC7B,MAAM,gBAAgB,SAAS,KAAK,IAAI;EACxC,MAAM,gBAAgB,8BAA8B,OAAO;EAC3D,MAAM,WAAW,iBAAiB,eAAe,SAAS,KAAK,GAAG;AAElE,MAAI,WAAW,cAAc;AAC3B,iBAAc,SAAS;AACvB;EACD;AAED,SAAO,AAAC,OAAO,eAAuB,eAAe,GAAG,SAAS,KAAK;CACvE,EAAC;AACH;AASD,SAAgB,uCAKdC,GACAC,MAsBA;CACA,MAAM,SAAS,EAAE;CACjB,MAAM,EACJ,oBAAoB,MACpB,eACA,mBAAmB,0BAA0B,MAC9C,GAAG;CAEJ,MAAM,cAAc,OAAO;AAG3B,QAAO,SAAS,mBACdC,MAGA;AACA,SAAO,eAAe,cACpBC,UACA;GACA,IAAIC;AACJ,OAAI;AACF,UAAO,MAAM,iBAAiB,IAAK,CAAE;AACrC,QAAI,qBAAqB,WAAW,SAAS,CAE3C,KAAI;AACF,gBAAW,iBAAiB,SAAS;IACtC,QAAO;AACN,WAAM,IAAI,UAAU;MAClB,MAAM;MACN,SAAS;KACV;IACF;aACQ,aAAa,WAAW,SAAS,CAC1C,YAAW,YAAY,MAAM,YAAY,SAAS;IAGpD,MAAM,OAAO,KAAK,KAAK,sBACnB,MAAM,KAAK,SAAgB,GAC3B,MAAM,KAAK;KACT;KACA;KACA,MAAM;KACN,aAAa,YAAY;KACzB,MAAM,KAAK,KAAK;KAEhB;IACD,EAAC;IAEN,MAAM,kBAAkB,sBAAsB,QAAQ,EACpD,QAAQ,EACN,KACD,EACF,EAAC;AACF,WAAO;GACR,SAAQ,OAAO;IACd,MAAM,QAAQ,wBAAwB,MAAM;AAE5C,SAAK,UAAU;KACb;KACA;KACA,OAAO;KACP,MAAM;KACN,MAAM,KAAK,KAAK;IACjB,EAAC;AAEF,QAAI,wBACF,mBAAkB,MAAM;IAG1B,MAAM,QAAQ,cAAc;KAC1B;KACA;KACA;KACA,OAAO;KACP,MAAM;KACN,MAAM,KAAK,KAAK;IACjB,EAAC;AAEF,WAAO,sBAAsB,EAAE,SAAS,EACtC,OAAO,MACR,EAAC;GACH;EACF;CAGF;AACF;AAGD,eAAsB,gCAAgCC,KAAc;CAClE,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,MAAM;AAErC,YAAW,aAAa,SACtB,QAAO,IAAI,SACT,KAAK,UAAU;EACb,aAAa;EACb,OAAO;CACR,EAAC,EACF,EAAE,QAAQ,IAAK;AAInB,eAAc,SAAS;AACvB,QAAO,IAAI,SAAS,KAAK,UAAU;EAAE,aAAa;EAAM,KAAK,KAAK,KAAK;CAAE,EAAC,EAAE,EAC1E,QAAQ,IACT;AACF"}
@@ -0,0 +1,37 @@
1
+ import { AnyClientTypes, AnyProcedure, AnyRootTypes, AnyRouter, ProtectedIntersection, RouterRecord, inferProcedureInput, inferTransformedProcedureOutput } from "@trpc/server/unstable-core-do-not-import";
2
+ import { CreateTRPCClientOptions, Resolver, TRPCClient, TRPCUntypedClient } from "@trpc/client";
3
+ import { inferProcedureOutput } from "@trpc/server";
4
+
5
+ //#region src/app-dir/shared.d.ts
6
+ /**
7
+ * @internal
8
+ */
9
+
10
+ /**
11
+ * @internal
12
+ */
13
+ interface CreateTRPCNextAppRouterOptions<TRouter extends AnyRouter> {
14
+ config: () => CreateTRPCClientOptions<TRouter>;
15
+ }
16
+ /**
17
+ * @internal
18
+ */
19
+
20
+ /**
21
+ * @internal
22
+ */
23
+ interface ActionHandlerDef {
24
+ input?: any;
25
+ output?: any;
26
+ errorShape: any;
27
+ }
28
+ /**
29
+ * @internal
30
+ */
31
+ type inferActionDef<TRoot extends AnyClientTypes, TProc extends AnyProcedure> = {
32
+ input: inferProcedureInput<TProc>;
33
+ output: inferProcedureOutput<TProc>;
34
+ errorShape: TRoot['errorShape'];
35
+ }; //#endregion
36
+ export { ActionHandlerDef, CreateTRPCNextAppRouterOptions, inferActionDef };
37
+ //# sourceMappingURL=shared.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.mts","names":[],"sources":["../../src/app-dir/shared.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;AAsIc,UAxCG,8BAwCH,CAAA,gBAxCkD,SAwClD,CAAA,CAAA;EAAK,MAAA,EAAA,GAAA,GAvCH,uBAuCG,CAvCqB,OAuCrB,CAAA;;;;;;;;;UAhBF,gBAAA;;;;;;;;KAUL,6BACI,8BACA;SAEP,oBAAoB;UACnB,qBAAqB;cACjB"}
@@ -1,55 +1,37 @@
1
- import type { CreateTRPCClientOptions, Resolver, TRPCClient } from '@trpc/client';
2
- import { TRPCUntypedClient } from '@trpc/client';
3
- import type { inferProcedureOutput } from '@trpc/server';
4
- import type { AnyClientTypes, AnyProcedure, AnyQueryProcedure, AnyRootTypes, AnyRouter, inferProcedureInput, inferTransformedProcedureOutput, ProtectedIntersection, RouterRecord } from '@trpc/server/unstable-core-do-not-import';
1
+ import { CreateTRPCClientOptions, Resolver, TRPCClient, TRPCUntypedClient } from "@trpc/client";
2
+ import { AnyClientTypes, AnyProcedure, AnyRootTypes, AnyRouter, ProtectedIntersection, RouterRecord, inferProcedureInput, inferTransformedProcedureOutput } from "@trpc/server/unstable-core-do-not-import";
3
+ import { inferProcedureOutput } from "@trpc/server";
4
+
5
+ //#region src/app-dir/shared.d.ts
5
6
  /**
6
- * @internal
7
- */
8
- export type UseProcedureRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = {
9
- [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyQueryProcedure ? Resolver<{
10
- input: inferProcedureInput<$Value>;
11
- output: inferTransformedProcedureOutput<TRoot, $Value>;
12
- errorShape: TRoot['errorShape'];
13
- transformer: TRoot['transformer'];
14
- }> : $Value extends RouterRecord ? UseProcedureRecord<TRoot, $Value> : never : never;
15
- };
16
- export declare function createUseProxy<TRouter extends AnyRouter>(client: TRPCUntypedClient<TRouter> | TRPCClient<TRouter>): UseProcedureRecord<TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>;
17
- type NextAppRouterUse<TRouter extends AnyRouter> = {
18
- <TData extends Promise<unknown>[]>(cb: (t: UseProcedureRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']>) => [...TData]): {
19
- [TKey in keyof TData]: Awaited<TData[TKey]>;
20
- };
21
- <TData extends Promise<unknown>>(cb: (t: UseProcedureRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']>) => TData): Awaited<TData>;
22
- };
23
- type CreateTRPCNextAppRouterBase<TRouter extends AnyRouter> = {
24
- use: NextAppRouterUse<TRouter>;
25
- };
26
- export type CreateTRPCNextAppRouter<TRouter extends AnyRouter> = ProtectedIntersection<CreateTRPCNextAppRouterBase<TRouter>, UseProcedureRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']>>;
7
+ * @internal
8
+ */
9
+
27
10
  /**
28
11
  * @internal
29
12
  */
30
- export interface CreateTRPCNextAppRouterOptions<TRouter extends AnyRouter> {
31
- config: () => CreateTRPCClientOptions<TRouter>;
13
+ interface CreateTRPCNextAppRouterOptions<TRouter extends AnyRouter> {
14
+ config: () => CreateTRPCClientOptions<TRouter>;
32
15
  }
33
16
  /**
34
17
  * @internal
35
18
  */
36
- export declare function generateCacheTag(procedurePath: string, input: any): string;
37
- export declare function isFormData(value: unknown): value is FormData;
19
+
38
20
  /**
39
21
  * @internal
40
22
  */
41
- export interface ActionHandlerDef {
42
- input?: any;
43
- output?: any;
44
- errorShape: any;
23
+ interface ActionHandlerDef {
24
+ input?: any;
25
+ output?: any;
26
+ errorShape: any;
45
27
  }
46
28
  /**
47
29
  * @internal
48
30
  */
49
- export type inferActionDef<TRoot extends AnyClientTypes, TProc extends AnyProcedure> = {
50
- input: inferProcedureInput<TProc>;
51
- output: inferProcedureOutput<TProc>;
52
- errorShape: TRoot['errorShape'];
53
- };
54
- export {};
31
+ type inferActionDef<TRoot extends AnyClientTypes, TProc extends AnyProcedure> = {
32
+ input: inferProcedureInput<TProc>;
33
+ output: inferProcedureOutput<TProc>;
34
+ errorShape: TRoot['errorShape'];
35
+ }; //#endregion
36
+ export { ActionHandlerDef, CreateTRPCNextAppRouterOptions, inferActionDef };
55
37
  //# sourceMappingURL=shared.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/app-dir/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,QAAQ,EACR,UAAU,EACX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAoB,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,+BAA+B,EAC/B,qBAAqB,EACrB,YAAY,EACb,MAAM,0CAA0C,CAAC;AAGlD;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAC5B,KAAK,SAAS,YAAY,EAC1B,OAAO,SAAS,YAAY,IAC1B;KACD,IAAI,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,IA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BF,gBAAA;;;;;;;;KAUL,6BACI,8BACA;SAEP,oBAAoB;UACnB,qBAAqB;cACjB"}
@@ -1,20 +1,19 @@
1
- 'use strict';
2
-
3
- require('@trpc/client');
4
- require('@trpc/server/unstable-core-do-not-import');
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const __trpc_server_unstable_core_do_not_import = require_rolldown_runtime.__toESM(require("@trpc/server/unstable-core-do-not-import"));
3
+ const __trpc_client = require_rolldown_runtime.__toESM(require("@trpc/client"));
5
4
 
5
+ //#region src/app-dir/shared.ts
6
6
  /**
7
- * @internal
8
- */ function generateCacheTag(procedurePath, input) {
9
- return input ? `${procedurePath}?input=${JSON.stringify(input)}` : procedurePath;
7
+ * @internal
8
+ */
9
+ function generateCacheTag(procedurePath, input) {
10
+ return input ? `${procedurePath}?input=${JSON.stringify(input)}` : procedurePath;
10
11
  }
11
12
  function isFormData(value) {
12
- if (typeof FormData === 'undefined') {
13
- // FormData is not supported
14
- return false;
15
- }
16
- return value instanceof FormData;
13
+ if (typeof FormData === "undefined") return false;
14
+ return value instanceof FormData;
17
15
  }
18
16
 
17
+ //#endregion
19
18
  exports.generateCacheTag = generateCacheTag;
20
- exports.isFormData = isFormData;
19
+ exports.isFormData = isFormData;
@@ -1,17 +1,18 @@
1
- import '@trpc/client';
2
- import '@trpc/server/unstable-core-do-not-import';
1
+ import { createRecursiveProxy } from "@trpc/server/unstable-core-do-not-import";
2
+ import { TRPCUntypedClient } from "@trpc/client";
3
3
 
4
+ //#region src/app-dir/shared.ts
4
5
  /**
5
- * @internal
6
- */ function generateCacheTag(procedurePath, input) {
7
- return input ? `${procedurePath}?input=${JSON.stringify(input)}` : procedurePath;
6
+ * @internal
7
+ */
8
+ function generateCacheTag(procedurePath, input) {
9
+ return input ? `${procedurePath}?input=${JSON.stringify(input)}` : procedurePath;
8
10
  }
9
11
  function isFormData(value) {
10
- if (typeof FormData === 'undefined') {
11
- // FormData is not supported
12
- return false;
13
- }
14
- return value instanceof FormData;
12
+ if (typeof FormData === "undefined") return false;
13
+ return value instanceof FormData;
15
14
  }
16
15
 
16
+ //#endregion
17
17
  export { generateCacheTag, isFormData };
18
+ //# sourceMappingURL=shared.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.mjs","names":["procedurePath: string","input: any","value: unknown"],"sources":["../../src/app-dir/shared.ts"],"sourcesContent":["import type {\n CreateTRPCClientOptions,\n Resolver,\n TRPCClient,\n} from '@trpc/client';\nimport { getUntypedClient, TRPCUntypedClient } from '@trpc/client';\nimport type { inferProcedureOutput } from '@trpc/server';\nimport type {\n AnyClientTypes,\n AnyProcedure,\n AnyQueryProcedure,\n AnyRootTypes,\n AnyRouter,\n inferProcedureInput,\n inferTransformedProcedureOutput,\n ProtectedIntersection,\n RouterRecord,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { createRecursiveProxy } from '@trpc/server/unstable-core-do-not-import';\n\n/**\n * @internal\n */\nexport type UseProcedureRecord<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyQueryProcedure\n ? Resolver<{\n input: inferProcedureInput<$Value>;\n output: inferTransformedProcedureOutput<TRoot, $Value>;\n errorShape: TRoot['errorShape'];\n transformer: TRoot['transformer'];\n }>\n : $Value extends RouterRecord\n ? UseProcedureRecord<TRoot, $Value>\n : never\n : never;\n};\n\nexport function createUseProxy<TRouter extends AnyRouter>(\n client: TRPCUntypedClient<TRouter> | TRPCClient<TRouter>,\n) {\n const untypedClient: TRPCUntypedClient<TRouter> =\n client instanceof TRPCUntypedClient ? client : getUntypedClient(client);\n\n return createRecursiveProxy<\n UseProcedureRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >\n >((opts) => {\n const path = opts.path.join('.');\n\n return untypedClient.query(path, ...opts.args);\n });\n}\n\ntype NextAppRouterUse<TRouter extends AnyRouter> = {\n <TData extends Promise<unknown>[]>(\n cb: (\n t: UseProcedureRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >,\n ) => [...TData],\n ): {\n [TKey in keyof TData]: Awaited<TData[TKey]>;\n };\n <TData extends Promise<unknown>>(\n cb: (\n t: UseProcedureRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >,\n ) => TData,\n ): Awaited<TData>;\n};\ntype CreateTRPCNextAppRouterBase<TRouter extends AnyRouter> = {\n use: NextAppRouterUse<TRouter>;\n};\nexport type CreateTRPCNextAppRouter<TRouter extends AnyRouter> =\n ProtectedIntersection<\n CreateTRPCNextAppRouterBase<TRouter>,\n UseProcedureRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >\n >;\n\n/**\n * @internal\n */\nexport interface CreateTRPCNextAppRouterOptions<TRouter extends AnyRouter> {\n config: () => CreateTRPCClientOptions<TRouter>;\n}\n\n/**\n * @internal\n */\nexport function generateCacheTag(procedurePath: string, input: any) {\n return input\n ? `${procedurePath}?input=${JSON.stringify(input)}`\n : procedurePath;\n}\n\nexport function isFormData(value: unknown): value is FormData {\n if (typeof FormData === 'undefined') {\n // FormData is not supported\n return false;\n }\n return value instanceof FormData;\n}\n\n/**\n * @internal\n */\nexport interface ActionHandlerDef {\n input?: any;\n output?: any;\n errorShape: any;\n}\n\n// ts-prune-ignore-next\n/**\n * @internal\n */\nexport type inferActionDef<\n TRoot extends AnyClientTypes,\n TProc extends AnyProcedure,\n> = {\n input: inferProcedureInput<TProc>;\n output: inferProcedureOutput<TProc>;\n errorShape: TRoot['errorShape'];\n};\n"],"mappings":";;;;;;;AAqGA,SAAgB,iBAAiBA,eAAuBC,OAAY;AAClE,QAAO,SACF,EAAE,cAAc,SAAS,KAAK,UAAU,MAAM,CAAC,IAChD;AACL;AAED,SAAgB,WAAWC,OAAmC;AAC5D,YAAW,aAAa,YAEtB,QAAO;AAET,QAAO,iBAAiB;AACzB"}
@@ -0,0 +1,33 @@
1
+ import { AnyProcedure, AnyRootTypes, ProcedureType, RouterRecord, inferProcedureInput, inferTransformedProcedureOutput } from "@trpc/server/unstable-core-do-not-import";
2
+ import { Resolver } from "@trpc/client";
3
+
4
+ //#region src/app-dir/types.d.ts
5
+ type ResolverDef = {
6
+ input: any;
7
+ output: any;
8
+ transformer: boolean;
9
+ errorShape: any;
10
+ };
11
+ type DecorateProcedureServer<TType extends ProcedureType, TDef extends ResolverDef> = TType extends 'query' ? {
12
+ query: Resolver<TDef>;
13
+ revalidate: (input?: TDef['input']) => Promise<{
14
+ revalidated: false;
15
+ error: string;
16
+ } | {
17
+ revalidated: true;
18
+ }>;
19
+ } : TType extends 'mutation' ? {
20
+ mutate: Resolver<TDef>;
21
+ } : TType extends 'subscription' ? {
22
+ subscribe: Resolver<TDef>;
23
+ } : never;
24
+ type NextAppDirDecorateRouterRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyProcedure ? DecorateProcedureServer<$Value['_def']['type'], {
25
+ input: inferProcedureInput<$Value>;
26
+ output: inferTransformedProcedureOutput<TRoot, $Value>;
27
+ errorShape: TRoot['errorShape'];
28
+ transformer: TRoot['transformer'];
29
+ }> : $Value extends RouterRecord ? NextAppDirDecorateRouterRecord<TRoot, $Value> : never : never };
30
+
31
+ //#endregion
32
+ export { NextAppDirDecorateRouterRecord };
33
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/app-dir/types.ts"],"sourcesContent":[],"mappings":";;;;KAUK,WAAA;;EAAA,MAAA,EAAA,GAAA;EAOO,WAAA,EAAA,OAAA;EAAuB,UAAA,EAAA,GAAA;CAAA;AAEpB,KAFH,uBAEG,CAAA,cADC,aACD,EAAA,aAAA,WAAA,CAAA,GACX,KADW,SAAA,OAAA,GAAA;EAAW,KACtB,EAES,QAFT,CAEkB,IAFlB,CAAA;EAAK,UAEa,EAAA,CAAA,KAAA,CAAA,EAEN,IAFM,CAAA,OAAA,CAAA,EAAA,GAGX,OAHW,CAAA;IAAT,WAAA,EAAA,KAAA;IAEG,KAAA,EAAA,MAAA;EAAI,CAAA,GACT;IAIP,WAAA,EAAA,IAAA;EAAK,CAAA,CAAA;CAEoB,GAFzB,KAEY,SAAA,UAAA,GAAA;EAAQ,MAElB,EAFU,QAEV,CAFmB,IAEnB,CAAA;CAAK,GAAL,KAEwB,SAAA,cAAA,GAAA;EAAI,SAAb,EAAA,QAAA,CAAS,IAAT,CAAA;AAAQ,CAAA,GAAA,KAAA;AAIjB,KAAA,8BAA8B,CAAA,cAC1B,YAD0B,EAAA,gBAExB,YAFwB,CAAA,GAAA,WAAA,MAIzB,OAJyB,GAIf,OAJe,CAIP,IAJO,CAAA,SAAA,KAAA,OAAA,GAKpC,MALoC,SAKrB,YALqB,GAMlC,uBANkC,CAOhC,MAPgC,CAAA,MAAA,CAAA,CAAA,MAAA,CAAA,EAAA;EAC1B,KAAA,EAQG,mBARH,CAQuB,MARvB,CAAA;EACE,MAAA,EAQE,+BARF,CAQkC,KARlC,EAQyC,MARzC,CAAA;EAED,UAAA,EAOO,KAPP,CAAA,YAAA,CAAA;EAAU,WAAA,EAQF,KARE,CAAA,aAAA,CAAA;AAAO,CAAA,CAAA,GAW1B,MAX2B,SAWZ,YAXY,GAYzB,8BAZyB,CAYM,KAZN,EAYa,MAZb,CAAA,GAAA,KAAA,GAAA,KAAA,EAAI"}
@@ -1,31 +1,33 @@
1
- import type { Resolver } from '@trpc/client';
2
- import type { AnyProcedure, AnyRootTypes, inferProcedureInput, inferTransformedProcedureOutput, ProcedureType, RouterRecord } from '@trpc/server/unstable-core-do-not-import';
1
+ import { Resolver } from "@trpc/client";
2
+ import { AnyProcedure, AnyRootTypes, ProcedureType, RouterRecord, inferProcedureInput, inferTransformedProcedureOutput } from "@trpc/server/unstable-core-do-not-import";
3
+
4
+ //#region src/app-dir/types.d.ts
3
5
  type ResolverDef = {
4
- input: any;
5
- output: any;
6
- transformer: boolean;
7
- errorShape: any;
6
+ input: any;
7
+ output: any;
8
+ transformer: boolean;
9
+ errorShape: any;
8
10
  };
9
- export type DecorateProcedureServer<TType extends ProcedureType, TDef extends ResolverDef> = TType extends 'query' ? {
10
- query: Resolver<TDef>;
11
- revalidate: (input?: TDef['input']) => Promise<{
12
- revalidated: false;
13
- error: string;
14
- } | {
15
- revalidated: true;
16
- }>;
11
+ type DecorateProcedureServer<TType extends ProcedureType, TDef extends ResolverDef> = TType extends 'query' ? {
12
+ query: Resolver<TDef>;
13
+ revalidate: (input?: TDef['input']) => Promise<{
14
+ revalidated: false;
15
+ error: string;
16
+ } | {
17
+ revalidated: true;
18
+ }>;
17
19
  } : TType extends 'mutation' ? {
18
- mutate: Resolver<TDef>;
20
+ mutate: Resolver<TDef>;
19
21
  } : TType extends 'subscription' ? {
20
- subscribe: Resolver<TDef>;
22
+ subscribe: Resolver<TDef>;
21
23
  } : never;
22
- export type NextAppDirDecorateRouterRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = {
23
- [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyProcedure ? DecorateProcedureServer<$Value['_def']['type'], {
24
- input: inferProcedureInput<$Value>;
25
- output: inferTransformedProcedureOutput<TRoot, $Value>;
26
- errorShape: TRoot['errorShape'];
27
- transformer: TRoot['transformer'];
28
- }> : $Value extends RouterRecord ? NextAppDirDecorateRouterRecord<TRoot, $Value> : never : never;
29
- };
30
- export {};
24
+ type NextAppDirDecorateRouterRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyProcedure ? DecorateProcedureServer<$Value['_def']['type'], {
25
+ input: inferProcedureInput<$Value>;
26
+ output: inferTransformedProcedureOutput<TRoot, $Value>;
27
+ errorShape: TRoot['errorShape'];
28
+ transformer: TRoot['transformer'];
29
+ }> : $Value extends RouterRecord ? NextAppDirDecorateRouterRecord<TRoot, $Value> : never : never };
30
+
31
+ //#endregion
32
+ export { NextAppDirDecorateRouterRecord };
31
33
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/app-dir/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,+BAA+B,EAC/B,aAAa,EACb,YAAY,EACb,MAAM,0CAA0C,CAAC;AAElD,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,GAAG,CAAC;IACZ,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,GAAG,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,uBAAuB,CACjC,KAAK,SAAS,aAAa,EAC3B,IAAI,SAAS,WAAW,IACtB,KAAK,SAAS,OAAO,GACrB;IACE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACtB,UAAU,EAAE,CACV,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAClB,OAAO,CACV;QAAE,WAAW,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,WAAW,EAAE,IAAI,CAAA;KAAE,CAC9D,CAAC;CACH,GACD,KAAK,SAAS,UAAU,GACtB;IACE,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;CACxB,GACD,KAAK,SAAS,cAAc,GAC1B;IACE,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;CAC3B,GACD,KAAK,CAAC;AAEd,MAAM,MAAM,8BAA8B,CACxC,KAAK,SAAS,YAAY,EAC1B,OAAO,SAAS,YAAY,IAC1B;KACD,IAAI,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,MAAM,MAAM,GACvD,MAAM,SAAS,YAAY,GACz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SAKrB,YALqB,GAMlC,uBANkC,CAOhC,MAPgC,CAAA,MAAA,CAAA,CAAA,MAAA,CAAA,EAAA;EAC1B,KAAA,EAQG,mBARH,CAQuB,MARvB,CAAA;EACE,MAAA,EAQE,+BARF,CAQkC,KARlC,EAQyC,MARzC,CAAA;EAED,UAAA,EAOO,KAPP,CAAA,YAAA,CAAA;EAAU,WAAA,EAQF,KARE,CAAA,aAAA,CAAA;AAAO,CAAA,CAAA,GAW1B,MAX2B,SAWZ,YAXY,GAYzB,8BAZyB,CAYM,KAZN,EAYa,MAZb,CAAA,GAAA,KAAA,GAAA,KAAA,EAAI"}
@@ -0,0 +1,38 @@
1
+ import { WithTRPCNoSSROptions, WithTRPCSSROptions, withTRPC$1 as withTRPC } from "./withTRPC.mjs";
2
+ import { CreateReactUtils, DecorateRouterRecord, TRPCUseQueries, TRPCUseSuspenseQueries } from "@trpc/react-query/shared";
3
+ import { AnyRouter, ProtectedIntersection } from "@trpc/server/unstable-core-do-not-import";
4
+ import { NextPageContext } from "next/types";
5
+
6
+ //#region src/createTRPCNext.d.ts
7
+ /**
8
+ * @internal
9
+ */
10
+ /**
11
+ * @internal
12
+ */
13
+ interface CreateTRPCNextBase<TRouter extends AnyRouter, TSSRContext extends NextPageContext> {
14
+ /**
15
+ * @deprecated renamed to `useUtils` and will be removed in a future tRPC version
16
+ *
17
+ * @see https://trpc.io/docs/v11/client/react/useUtils
18
+ */
19
+ useContext(): CreateReactUtils<TRouter, TSSRContext>;
20
+ /**
21
+ * @see https://trpc.io/docs/v11/client/react/useUtils
22
+ */
23
+ useUtils(): CreateReactUtils<TRouter, TSSRContext>;
24
+ withTRPC: ReturnType<typeof withTRPC<TRouter, TSSRContext>>;
25
+ useQueries: TRPCUseQueries<TRouter>;
26
+ useSuspenseQueries: TRPCUseSuspenseQueries<TRouter>;
27
+ }
28
+ /**
29
+ * @internal
30
+ */
31
+ type CreateTRPCNext<TRouter extends AnyRouter, TSSRContext extends NextPageContext> = ProtectedIntersection<CreateTRPCNextBase<TRouter, TSSRContext>, DecorateRouterRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']>>;
32
+ declare function createTRPCNext<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): CreateTRPCNext<TRouter, TSSRContext>;
33
+
34
+ //#endregion
35
+ //# sourceMappingURL=createTRPCNext.d.ts.map
36
+
37
+ export { CreateTRPCNext, CreateTRPCNextBase, createTRPCNext as createTRPCNext$1 };
38
+ //# sourceMappingURL=createTRPCNext.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTRPCNext.d.mts","names":[],"sources":["../src/createTRPCNext.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;UA0BiB,mCACC,+BACI;EAFL;;;;;EASuB,UAAE,EAAA,EAA1B,gBAA0B,CAAT,OAAS,EAAA,WAAA,CAAA;EAAW;;;EAIF,QAArC,EAAA,EAAA,gBAAA,CAAiB,OAAjB,EAA0B,WAA1B,CAAA;EAAgB,QACS,EAA3B,UAA2B,CAAA,OAAT,QAAS,CAAA,OAAA,EAAS,WAAT,CAAA,CAAA;EAAO,UAAE,EAClC,cADkC,CACnB,OADmB,CAAA;EAAW,kBAA7B,EAER,sBAFQ,CAEe,OAFf,CAAA;;;;;AAER,KAMV,cANU,CAAA,gBAOJ,SAPI,EAAA,oBAQA,eARA,CAAA,GASlB,qBATkB,CAUpB,kBAVoB,CAUD,OAVC,EAUQ,WAVR,CAAA,EAWpB,oBAXoB,CAYlB,OAZkB,CAAA,MAAA,CAAA,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,EAalB,OAbkB,CAAA,MAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA;AAAsB,iBAiB5B,cAjB4B,CAAA,gBAkB1B,SAlB0B,EAAA,oBAmBtB,eAnBsB,GAmBJ,eAnBI,CAAA,CAAA,IAAA,EAqBpC,oBArBoC,CAqBf,OArBe,CAAA,GAqBJ,kBArBI,CAqBe,OArBf,CAAA,CAAA,EAsBzC,cAtByC,CAsB1B,OAtB0B,EAsBjB,WAtBiB,CAAA"}