@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.
- package/app-dir/client/package.json +1 -0
- package/app-dir/links/nextCache/package.json +1 -0
- package/app-dir/links/nextHttp/package.json +1 -0
- package/app-dir/server/package.json +1 -0
- package/dist/_virtual/rolldown_runtime.js +30 -0
- package/dist/app-dir/client.d.mts +13 -0
- package/dist/app-dir/client.d.mts.map +1 -0
- package/dist/app-dir/client.d.ts +12 -5
- package/dist/app-dir/client.d.ts.map +1 -1
- package/dist/app-dir/client.js +25 -43
- package/dist/app-dir/client.mjs +24 -40
- package/dist/app-dir/client.mjs.map +1 -0
- package/dist/app-dir/create-action-hook.d.mts +47 -0
- package/dist/app-dir/create-action-hook.d.mts.map +1 -0
- package/dist/app-dir/create-action-hook.d.ts +33 -36
- package/dist/app-dir/create-action-hook.d.ts.map +1 -1
- package/dist/app-dir/create-action-hook.js +85 -101
- package/dist/app-dir/create-action-hook.mjs +84 -98
- package/dist/app-dir/create-action-hook.mjs.map +1 -0
- package/dist/app-dir/links/nextCache.d.mts +16 -0
- package/dist/app-dir/links/nextCache.d.mts.map +1 -0
- package/dist/app-dir/links/nextCache.d.ts +13 -9
- package/dist/app-dir/links/nextCache.d.ts.map +1 -1
- package/dist/app-dir/links/nextCache.js +44 -58
- package/dist/app-dir/links/nextCache.mjs +43 -55
- package/dist/app-dir/links/nextCache.mjs.map +1 -0
- package/dist/app-dir/links/nextHttp.d.mts +19 -0
- package/dist/app-dir/links/nextHttp.d.mts.map +1 -0
- package/dist/app-dir/links/nextHttp.d.ts +12 -8
- package/dist/app-dir/links/nextHttp.d.ts.map +1 -1
- package/dist/app-dir/links/nextHttp.js +31 -35
- package/dist/app-dir/links/nextHttp.mjs +30 -32
- package/dist/app-dir/links/nextHttp.mjs.map +1 -0
- package/dist/app-dir/server.d.mts +36 -0
- package/dist/app-dir/server.d.mts.map +1 -0
- package/dist/app-dir/server.d.ts +30 -24
- package/dist/app-dir/server.d.ts.map +1 -1
- package/dist/app-dir/server.js +86 -112
- package/dist/app-dir/server.mjs +85 -109
- package/dist/app-dir/server.mjs.map +1 -0
- package/dist/app-dir/shared.d.mts +37 -0
- package/dist/app-dir/shared.d.mts.map +1 -0
- package/dist/app-dir/shared.d.ts +21 -39
- package/dist/app-dir/shared.d.ts.map +1 -1
- package/dist/app-dir/shared.js +12 -13
- package/dist/app-dir/shared.mjs +11 -10
- package/dist/app-dir/shared.mjs.map +1 -0
- package/dist/app-dir/types.d.mts +33 -0
- package/dist/app-dir/types.d.mts.map +1 -0
- package/dist/app-dir/types.d.ts +27 -25
- package/dist/app-dir/types.d.ts.map +1 -1
- package/dist/createTRPCNext.d.mts +38 -0
- package/dist/createTRPCNext.d.mts.map +1 -0
- package/dist/createTRPCNext.d.ts +30 -21
- package/dist/createTRPCNext.d.ts.map +1 -1
- package/dist/createTRPCNext.js +23 -35
- package/dist/createTRPCNext.mjs +22 -32
- package/dist/createTRPCNext.mjs.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -8
- package/dist/index.mjs +4 -2
- package/dist/ssrPrepass.d.mts +10 -0
- package/dist/ssrPrepass.d.mts.map +1 -0
- package/dist/ssrPrepass.d.ts +9 -2
- package/dist/ssrPrepass.d.ts.map +1 -1
- package/dist/ssrPrepass.js +99 -134
- package/dist/ssrPrepass.mjs +98 -131
- package/dist/ssrPrepass.mjs.map +1 -0
- package/dist/withTRPC.d.mts +55 -0
- package/dist/withTRPC.d.mts.map +1 -0
- package/dist/withTRPC.d.ts +47 -46
- package/dist/withTRPC.d.ts.map +1 -1
- package/dist/withTRPC.js +69 -82
- package/dist/withTRPC.mjs +68 -79
- package/dist/withTRPC.mjs.map +1 -0
- package/package.json +63 -33
- package/src/withTRPC.tsx +1 -2
- package/ssrPrepass/package.json +1 -0
- package/dist/index.d.ts.map +0 -1
|
@@ -1,39 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require__Users_julius_dev_trpc_packages_next_src_app_dir_shared = require('../shared.js');
|
|
3
|
+
const __trpc_client = require_rolldown_runtime.__toESM(require("@trpc/client"));
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
var shared = require('../shared.js');
|
|
5
|
-
|
|
6
|
-
// ts-prune-ignore-next
|
|
5
|
+
//#region src/app-dir/links/nextHttp.ts
|
|
7
6
|
function experimental_nextHttpLink(opts) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
return link(runtime)(ctx);
|
|
35
|
-
};
|
|
36
|
-
};
|
|
7
|
+
return (runtime) => {
|
|
8
|
+
return (ctx) => {
|
|
9
|
+
const { path, input, context } = ctx.op;
|
|
10
|
+
const cacheTag = require__Users_julius_dev_trpc_packages_next_src_app_dir_shared.generateCacheTag(path, input);
|
|
11
|
+
const requestRevalidate = typeof context["revalidate"] === "number" || context["revalidate"] === false ? context["revalidate"] : void 0;
|
|
12
|
+
const revalidate = requestRevalidate ?? opts.revalidate ?? false;
|
|
13
|
+
const _fetch = (url, fetchOpts) => {
|
|
14
|
+
return fetch(url, {
|
|
15
|
+
...fetchOpts,
|
|
16
|
+
next: {
|
|
17
|
+
revalidate,
|
|
18
|
+
tags: [cacheTag]
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const link = opts.batch ? (0, __trpc_client.httpBatchLink)({
|
|
23
|
+
...opts,
|
|
24
|
+
fetch: _fetch
|
|
25
|
+
}) : (0, __trpc_client.httpLink)({
|
|
26
|
+
...opts,
|
|
27
|
+
fetch: _fetch
|
|
28
|
+
});
|
|
29
|
+
return link(runtime)(ctx);
|
|
30
|
+
};
|
|
31
|
+
};
|
|
37
32
|
}
|
|
38
33
|
|
|
39
|
-
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.experimental_nextHttpLink = experimental_nextHttpLink;
|
|
@@ -1,37 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { generateCacheTag } from "../shared.mjs";
|
|
2
|
+
import { httpBatchLink, httpLink } from "@trpc/client";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
//#region src/app-dir/links/nextHttp.ts
|
|
5
5
|
function experimental_nextHttpLink(opts) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
return link(runtime)(ctx);
|
|
33
|
-
};
|
|
34
|
-
};
|
|
6
|
+
return (runtime) => {
|
|
7
|
+
return (ctx) => {
|
|
8
|
+
const { path, input, context } = ctx.op;
|
|
9
|
+
const cacheTag = generateCacheTag(path, input);
|
|
10
|
+
const requestRevalidate = typeof context["revalidate"] === "number" || context["revalidate"] === false ? context["revalidate"] : void 0;
|
|
11
|
+
const revalidate = requestRevalidate ?? opts.revalidate ?? false;
|
|
12
|
+
const _fetch = (url, fetchOpts) => {
|
|
13
|
+
return fetch(url, {
|
|
14
|
+
...fetchOpts,
|
|
15
|
+
next: {
|
|
16
|
+
revalidate,
|
|
17
|
+
tags: [cacheTag]
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const link = opts.batch ? httpBatchLink({
|
|
22
|
+
...opts,
|
|
23
|
+
fetch: _fetch
|
|
24
|
+
}) : httpLink({
|
|
25
|
+
...opts,
|
|
26
|
+
fetch: _fetch
|
|
27
|
+
});
|
|
28
|
+
return link(runtime)(ctx);
|
|
29
|
+
};
|
|
30
|
+
};
|
|
35
31
|
}
|
|
36
32
|
|
|
33
|
+
//#endregion
|
|
37
34
|
export { experimental_nextHttpLink };
|
|
35
|
+
//# sourceMappingURL=nextHttp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextHttp.mjs","names":["opts:\n | NextLinkSingleOptions<TRouter['_def']['_config']['$types']>\n | NextLinkBatchOptions<TRouter['_def']['_config']['$types']>","_fetch: NonNullable<HTTPLinkOptions<AnyRootTypes>['fetch']>"],"sources":["../../../src/app-dir/links/nextHttp.ts"],"sourcesContent":["import type {\n HTTPBatchLinkOptions,\n HTTPLinkOptions,\n TRPCLink,\n} from '@trpc/client';\nimport { httpBatchLink, httpLink } from '@trpc/client';\nimport type {\n AnyRootTypes,\n AnyRouter,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { generateCacheTag } from '../shared';\n\ninterface NextLinkBaseOptions {\n revalidate?: number | false;\n batch?: boolean;\n}\n\ntype NextLinkSingleOptions<TRoot extends AnyRootTypes> = NextLinkBaseOptions &\n Omit<HTTPLinkOptions<TRoot>, 'fetch'> & {\n batch?: false;\n };\n\ntype NextLinkBatchOptions<TRoot extends AnyRootTypes> = NextLinkBaseOptions &\n Omit<HTTPBatchLinkOptions<TRoot>, 'fetch'> & {\n batch: true;\n };\n\n// ts-prune-ignore-next\nexport function experimental_nextHttpLink<TRouter extends AnyRouter>(\n opts:\n | NextLinkSingleOptions<TRouter['_def']['_config']['$types']>\n | NextLinkBatchOptions<TRouter['_def']['_config']['$types']>,\n): TRPCLink<TRouter> {\n return (runtime) => {\n return (ctx) => {\n const { path, input, context } = ctx.op;\n const cacheTag = generateCacheTag(path, input);\n\n // Let per-request revalidate override global revalidate\n const requestRevalidate =\n typeof context['revalidate'] === 'number' ||\n context['revalidate'] === false\n ? context['revalidate']\n : undefined;\n\n const revalidate = requestRevalidate ?? opts.revalidate ?? false;\n\n const _fetch: NonNullable<HTTPLinkOptions<AnyRootTypes>['fetch']> = (\n url,\n fetchOpts,\n ) => {\n return fetch(url, {\n ...fetchOpts,\n // cache: 'no-cache',\n next: {\n revalidate,\n tags: [cacheTag],\n },\n });\n };\n const link = opts.batch\n ? httpBatchLink({\n ...(opts as any),\n fetch: _fetch,\n })\n : httpLink({\n ...(opts as any),\n fetch: _fetch,\n });\n\n return link(runtime)(ctx);\n };\n };\n}\n"],"mappings":";;;;AA4BA,SAAgB,0BACdA,MAGmB;AACnB,QAAO,CAAC,YAAY;AAClB,SAAO,CAAC,QAAQ;GACd,MAAM,EAAE,MAAM,OAAO,SAAS,GAAG,IAAI;GACrC,MAAM,WAAW,iBAAiB,MAAM,MAAM;GAG9C,MAAM,2BACG,QAAQ,kBAAkB,YACjC,QAAQ,kBAAkB,QACtB,QAAQ;GAGd,MAAM,aAAa,qBAAqB,KAAK,cAAc;GAE3D,MAAMC,SAA8D,CAClE,KACA,cACG;AACH,WAAO,MAAM,KAAK;KAChB,GAAG;KAEH,MAAM;MACJ;MACA,MAAM,CAAC,QAAS;KACjB;IACF,EAAC;GACH;GACD,MAAM,OAAO,KAAK,QACd,cAAc;IACZ,GAAI;IACJ,OAAO;GACR,EAAC,GACF,SAAS;IACP,GAAI;IACJ,OAAO;GACR,EAAC;AAEN,UAAO,KAAK,QAAQ,CAAC,IAAI;EAC1B;CACF;AACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ActionHandlerDef, CreateTRPCNextAppRouterOptions, inferActionDef } from "./shared.mjs";
|
|
2
|
+
import { NextAppDirDecorateRouterRecord } from "./types.mjs";
|
|
3
|
+
import { AnyProcedure, AnyRootTypes, AnyRouter, ErrorHandlerOptions, MaybePromise, RootConfig, Simplify, TRPCResponse, inferClientTypes } from "@trpc/server/unstable-core-do-not-import";
|
|
4
|
+
import { CreateContextCallback } from "@trpc/server";
|
|
5
|
+
|
|
6
|
+
//#region src/app-dir/server.d.ts
|
|
7
|
+
declare function experimental_createTRPCNextAppDirServer<TRouter extends AnyRouter>(opts: CreateTRPCNextAppRouterOptions<TRouter>): NextAppDirDecorateRouterRecord<TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>;
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
type TRPCActionHandler<TDef extends ActionHandlerDef> = (input: FormData | TDef['input']) => Promise<TRPCResponse<TDef['output'], TDef['errorShape']>>;
|
|
12
|
+
declare function experimental_createServerActionHandler<TInstance extends {
|
|
13
|
+
_config: RootConfig<AnyRootTypes>;
|
|
14
|
+
}>(t: TInstance, opts: CreateContextCallback<TInstance['_config']['$types']['ctx'], () => MaybePromise<TInstance['_config']['$types']['ctx']>> & {
|
|
15
|
+
/**
|
|
16
|
+
* Transform form data to a `Record` before passing it to the procedure
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
normalizeFormData?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Called when an error occurs in the handler
|
|
22
|
+
*/
|
|
23
|
+
onError?: (opts: ErrorHandlerOptions<TInstance['_config']['$types']['ctx']>) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Rethrow errors that should be handled by Next.js
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
rethrowNextErrors?: boolean;
|
|
29
|
+
}): <TProc extends AnyProcedure>(proc: TProc) => TRPCActionHandler<Simplify<inferActionDef<inferClientTypes<TInstance>, TProc>>>;
|
|
30
|
+
declare function experimental_revalidateEndpoint(req: Request): Promise<Response>;
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
//# sourceMappingURL=server.d.ts.map
|
|
34
|
+
|
|
35
|
+
export { ActionHandlerDef, TRPCActionHandler, experimental_createServerActionHandler, experimental_createTRPCNextAppDirServer, experimental_revalidateEndpoint };
|
|
36
|
+
//# sourceMappingURL=server.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.mts","names":[],"sources":["../../src/app-dir/server.ts"],"sourcesContent":[],"mappings":";;;;;;iBAwCgB,wDACE,iBACV,+BAA+B,WAAQ,+BAAA,sCAAA;AAF/C;;;AAEuC,KAkC3B,iBAlC2B,CAAA,aAkCI,gBAlCJ,CAAA,GAAA,CAAA,KAAA,EAmC9B,QAnC8B,GAmCnB,IAnCmB,CAAA,OAAA,CAAA,EAAA,GAoClC,OApCkC,CAoC1B,YApC0B,CAoCb,IApCa,CAAA,QAAA,CAAA,EAoCG,IApCH,CAAA,YAAA,CAAA,CAAA,CAAA;AAA/B,iBAsCQ,sCAtCR,CAAA,kBAAA;EAA8B,OAAS,EAwClC,UAxCkC,CAwCvB,YAxCuB,CAAA;CAAA,CAAA,CAAA,CAAA,EA2C1C,SA3C0C,EAAA,IAAA,EA4CvC,qBA5CuC,CA6C3C,SA7C2C,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,KAAA,CAAA,EAAA,GAAA,GA8CrC,YA9CqC,CA8CxB,SA9CwB,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,GAAA;EAAA;AAAA;;;;EAkCnC;;;EAA+C,OAClD,CAAA,EAAA,CAAA,IAAA,EAsBG,mBAtBH,CAsBuB,SAtBvB,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,KAAA,CAAA,CAAA,EAAA,GAAA,IAAA;EAAQ;;;;EACQ,iBAApB,CAAA,EAAA,OAAA;AAAO,CAAA,CAAA,EAAA,CAAA,cAyCuC,YAzCvC,CAAA,CAAA,IAAA,EA0CF,KA1CE,EAAA,GA2CP,iBA3CO,CA4CR,QA5CQ,CA4CC,cA5CD,CA4CgB,gBA5ChB,CA4CiC,SA5CjC,CAAA,EA4C6C,KA5C7C,CAAA,CAAA,CAAA;AAEI,iBAqHM,+BAAA,CArHgC,GAAA,EAqHK,OArHL,CAAA,EAqHY,OArHZ,CAqHY,QArHZ,CAAA"}
|
package/dist/app-dir/server.d.ts
CHANGED
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { ActionHandlerDef, CreateTRPCNextAppRouterOptions, inferActionDef } from "./shared.js";
|
|
2
|
+
import { NextAppDirDecorateRouterRecord } from "./types.js";
|
|
3
|
+
import { AnyProcedure, AnyRootTypes, AnyRouter, ErrorHandlerOptions, MaybePromise, RootConfig, Simplify, TRPCResponse, inferClientTypes } from "@trpc/server/unstable-core-do-not-import";
|
|
4
|
+
import { CreateContextCallback } from "@trpc/server";
|
|
5
|
+
|
|
6
|
+
//#region src/app-dir/server.d.ts
|
|
7
|
+
declare function experimental_createTRPCNextAppDirServer<TRouter extends AnyRouter>(opts: CreateTRPCNextAppRouterOptions<TRouter>): NextAppDirDecorateRouterRecord<TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>;
|
|
7
8
|
/**
|
|
8
9
|
* @internal
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
type TRPCActionHandler<TDef extends ActionHandlerDef> = (input: FormData | TDef['input']) => Promise<TRPCResponse<TDef['output'], TDef['errorShape']>>;
|
|
12
|
+
declare function experimental_createServerActionHandler<TInstance extends {
|
|
13
|
+
_config: RootConfig<AnyRootTypes>;
|
|
13
14
|
}>(t: TInstance, opts: CreateContextCallback<TInstance['_config']['$types']['ctx'], () => MaybePromise<TInstance['_config']['$types']['ctx']>> & {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Transform form data to a `Record` before passing it to the procedure
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
normalizeFormData?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Called when an error occurs in the handler
|
|
22
|
+
*/
|
|
23
|
+
onError?: (opts: ErrorHandlerOptions<TInstance['_config']['$types']['ctx']>) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Rethrow errors that should be handled by Next.js
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
rethrowNextErrors?: boolean;
|
|
28
29
|
}): <TProc extends AnyProcedure>(proc: TProc) => TRPCActionHandler<Simplify<inferActionDef<inferClientTypes<TInstance>, TProc>>>;
|
|
29
|
-
|
|
30
|
+
declare function experimental_revalidateEndpoint(req: Request): Promise<Response>;
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
//# sourceMappingURL=server.d.ts.map
|
|
34
|
+
|
|
35
|
+
export { ActionHandlerDef, TRPCActionHandler, experimental_createServerActionHandler, experimental_createTRPCNextAppDirServer, experimental_revalidateEndpoint };
|
|
30
36
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","
|
|
1
|
+
{"version":3,"file":"server.d.ts","names":[],"sources":["../../src/app-dir/server.ts"],"sourcesContent":[],"mappings":";;;;;;iBAwCgB,wDACE,iBACV,+BAA+B,WAAQ,+BAAA,sCAAA;AAF/C;;;AAEuC,KAkC3B,iBAlC2B,CAAA,aAkCI,gBAlCJ,CAAA,GAAA,CAAA,KAAA,EAmC9B,QAnC8B,GAmCnB,IAnCmB,CAAA,OAAA,CAAA,EAAA,GAoClC,OApCkC,CAoC1B,YApC0B,CAoCb,IApCa,CAAA,QAAA,CAAA,EAoCG,IApCH,CAAA,YAAA,CAAA,CAAA,CAAA;AAA/B,iBAsCQ,sCAtCR,CAAA,kBAAA;EAA8B,OAAS,EAwClC,UAxCkC,CAwCvB,YAxCuB,CAAA;CAAA,CAAA,CAAA,CAAA,EA2C1C,SA3C0C,EAAA,IAAA,EA4CvC,qBA5CuC,CA6C3C,SA7C2C,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,KAAA,CAAA,EAAA,GAAA,GA8CrC,YA9CqC,CA8CxB,SA9CwB,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,GAAA;EAAA;AAAA;;;;EAkCnC;;;EAA+C,OAClD,CAAA,EAAA,CAAA,IAAA,EAsBG,mBAtBH,CAsBuB,SAtBvB,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,KAAA,CAAA,CAAA,EAAA,GAAA,IAAA;EAAQ;;;;EACQ,iBAApB,CAAA,EAAA,OAAA;AAAO,CAAA,CAAA,EAAA,CAAA,cAyCuC,YAzCvC,CAAA,CAAA,IAAA,EA0CF,KA1CE,EAAA,GA2CP,iBA3CO,CA4CR,QA5CQ,CA4CC,cA5CD,CA4CgB,gBA5ChB,CA4CiC,SA5CjC,CAAA,EA4C6C,KA5C7C,CAAA,CAAA,CAAA;AAEI,iBAqHM,+BAAA,CArHgC,GAAA,EAqHK,OArHL,CAAA,EAqHY,OArHZ,CAqHY,QArHZ,CAAA"}
|
package/dist/app-dir/server.js
CHANGED
|
@@ -1,122 +1,96 @@
|
|
|
1
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require__Users_julius_dev_trpc_packages_next_src_app_dir_shared = require('./shared.js');
|
|
3
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
4
|
+
const __trpc_server_unstable_core_do_not_import = require_rolldown_runtime.__toESM(require("@trpc/server/unstable-core-do-not-import"));
|
|
5
|
+
const __trpc_client = require_rolldown_runtime.__toESM(require("@trpc/client"));
|
|
6
|
+
const __trpc_server_adapters_next_app_dir = require_rolldown_runtime.__toESM(require("@trpc/server/adapters/next-app-dir"));
|
|
7
|
+
const next_cache = require_rolldown_runtime.__toESM(require("next/cache"));
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
var nextAppDir = require('@trpc/server/adapters/next-app-dir');
|
|
5
|
-
var unstableCoreDoNotImport = require('@trpc/server/unstable-core-do-not-import');
|
|
6
|
-
var cache = require('next/cache');
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var shared = require('./shared.js');
|
|
9
|
-
|
|
10
|
-
/// <reference types="next" />
|
|
11
|
-
// ts-prune-ignore-next
|
|
9
|
+
//#region src/app-dir/server.ts
|
|
12
10
|
function experimental_createTRPCNextAppDirServer(opts) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
return client$1[procedureType](procedurePath, ...callOpts.args);
|
|
33
|
-
});
|
|
11
|
+
const getClient = (0, react.cache)(() => {
|
|
12
|
+
const config = opts.config();
|
|
13
|
+
return (0, __trpc_client.createTRPCUntypedClient)(config);
|
|
14
|
+
});
|
|
15
|
+
return (0, __trpc_server_unstable_core_do_not_import.createRecursiveProxy)((callOpts) => {
|
|
16
|
+
const client = getClient();
|
|
17
|
+
const pathCopy = [...callOpts.path];
|
|
18
|
+
const action = pathCopy.pop();
|
|
19
|
+
const procedurePath = pathCopy.join(".");
|
|
20
|
+
const procedureType = (0, __trpc_client.clientCallTypeToProcedureType)(action);
|
|
21
|
+
const cacheTag = require__Users_julius_dev_trpc_packages_next_src_app_dir_shared.generateCacheTag(procedurePath, callOpts.args[0]);
|
|
22
|
+
if (action === "revalidate") {
|
|
23
|
+
(0, next_cache.revalidateTag)(cacheTag);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
return client[procedureType](procedurePath, ...callOpts.args);
|
|
27
|
+
});
|
|
34
28
|
}
|
|
35
29
|
function experimental_createServerActionHandler(t, opts) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const shape = unstableCoreDoNotImport.getErrorShape({
|
|
86
|
-
config,
|
|
87
|
-
ctx,
|
|
88
|
-
error,
|
|
89
|
-
input: rawInput,
|
|
90
|
-
path: '',
|
|
91
|
-
type: proc._def.type
|
|
92
|
-
});
|
|
93
|
-
return unstableCoreDoNotImport.transformTRPCResponse(t._config, {
|
|
94
|
-
error: shape
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
};
|
|
30
|
+
const config = t._config;
|
|
31
|
+
const { normalizeFormData = true, createContext, rethrowNextErrors: shouldRethrowNextErrors = true } = opts;
|
|
32
|
+
const transformer = config.transformer;
|
|
33
|
+
return function createServerAction(proc) {
|
|
34
|
+
return async function actionHandler(rawInput) {
|
|
35
|
+
let ctx = void 0;
|
|
36
|
+
try {
|
|
37
|
+
ctx = await createContext?.() ?? {};
|
|
38
|
+
if (normalizeFormData && require__Users_julius_dev_trpc_packages_next_src_app_dir_shared.isFormData(rawInput)) try {
|
|
39
|
+
rawInput = (0, __trpc_server_unstable_core_do_not_import.formDataToObject)(rawInput);
|
|
40
|
+
} catch {
|
|
41
|
+
throw new __trpc_server_unstable_core_do_not_import.TRPCError({
|
|
42
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
43
|
+
message: "Failed to convert FormData to an object"
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else if (rawInput && !require__Users_julius_dev_trpc_packages_next_src_app_dir_shared.isFormData(rawInput)) rawInput = transformer.input.deserialize(rawInput);
|
|
47
|
+
const data = proc._def.experimental_caller ? await proc(rawInput) : await proc({
|
|
48
|
+
input: void 0,
|
|
49
|
+
ctx,
|
|
50
|
+
path: "",
|
|
51
|
+
getRawInput: async () => rawInput,
|
|
52
|
+
type: proc._def.type,
|
|
53
|
+
signal: void 0
|
|
54
|
+
});
|
|
55
|
+
const transformedJSON = (0, __trpc_server_unstable_core_do_not_import.transformTRPCResponse)(config, { result: { data } });
|
|
56
|
+
return transformedJSON;
|
|
57
|
+
} catch (cause) {
|
|
58
|
+
const error = (0, __trpc_server_unstable_core_do_not_import.getTRPCErrorFromUnknown)(cause);
|
|
59
|
+
opts.onError?.({
|
|
60
|
+
ctx,
|
|
61
|
+
error,
|
|
62
|
+
input: rawInput,
|
|
63
|
+
path: "",
|
|
64
|
+
type: proc._def.type
|
|
65
|
+
});
|
|
66
|
+
if (shouldRethrowNextErrors) (0, __trpc_server_adapters_next_app_dir.rethrowNextErrors)(error);
|
|
67
|
+
const shape = (0, __trpc_server_unstable_core_do_not_import.getErrorShape)({
|
|
68
|
+
config,
|
|
69
|
+
ctx,
|
|
70
|
+
error,
|
|
71
|
+
input: rawInput,
|
|
72
|
+
path: "",
|
|
73
|
+
type: proc._def.type
|
|
74
|
+
});
|
|
75
|
+
return (0, __trpc_server_unstable_core_do_not_import.transformTRPCResponse)(t._config, { error: shape });
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
99
79
|
}
|
|
100
|
-
// ts-prune-ignore-next
|
|
101
80
|
async function experimental_revalidateEndpoint(req) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return new Response(JSON.stringify({
|
|
113
|
-
revalidated: true,
|
|
114
|
-
now: Date.now()
|
|
115
|
-
}), {
|
|
116
|
-
status: 200
|
|
117
|
-
});
|
|
81
|
+
const { cacheTag } = await req.json();
|
|
82
|
+
if (typeof cacheTag !== "string") return new Response(JSON.stringify({
|
|
83
|
+
revalidated: false,
|
|
84
|
+
error: "cacheTag must be a string"
|
|
85
|
+
}), { status: 400 });
|
|
86
|
+
(0, next_cache.revalidateTag)(cacheTag);
|
|
87
|
+
return new Response(JSON.stringify({
|
|
88
|
+
revalidated: true,
|
|
89
|
+
now: Date.now()
|
|
90
|
+
}), { status: 200 });
|
|
118
91
|
}
|
|
119
92
|
|
|
93
|
+
//#endregion
|
|
120
94
|
exports.experimental_createServerActionHandler = experimental_createServerActionHandler;
|
|
121
95
|
exports.experimental_createTRPCNextAppDirServer = experimental_createTRPCNextAppDirServer;
|
|
122
|
-
exports.experimental_revalidateEndpoint = experimental_revalidateEndpoint;
|
|
96
|
+
exports.experimental_revalidateEndpoint = experimental_revalidateEndpoint;
|