@trpc/server 11.0.0-next.324 → 11.0.0-next.325
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/adapters/next-app-dir/index.d.ts +1 -0
- package/adapters/next-app-dir/index.js +1 -0
- package/dist/adapters/aws-lambda/index.js +1 -0
- package/dist/adapters/aws-lambda/index.mjs +1 -0
- package/dist/adapters/aws-lambda/utils.js +1 -0
- package/dist/adapters/aws-lambda/utils.mjs +1 -0
- package/dist/adapters/fastify/fastifyRequestHandler.js +1 -0
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +1 -0
- package/dist/adapters/fetch/fetchRequestHandler.js +1 -0
- package/dist/adapters/fetch/fetchRequestHandler.mjs +1 -0
- package/dist/adapters/next-app-dir/formDataToObject.d.ts +2 -0
- package/dist/adapters/next-app-dir/formDataToObject.d.ts.map +1 -0
- package/dist/adapters/next-app-dir/formDataToObject.js +34 -0
- package/dist/adapters/next-app-dir/formDataToObject.mjs +32 -0
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts +24 -0
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts.map +1 -0
- package/dist/adapters/next-app-dir/nextAppDirCaller.js +79 -0
- package/dist/adapters/next-app-dir/nextAppDirCaller.mjs +77 -0
- package/dist/adapters/next-app-dir/notFound.d.ts +7 -0
- package/dist/adapters/next-app-dir/notFound.d.ts.map +1 -0
- package/dist/adapters/next-app-dir/notFound.js +16 -0
- package/dist/adapters/next-app-dir/notFound.mjs +14 -0
- package/dist/adapters/next-app-dir/redirect.d.ts +15 -0
- package/dist/adapters/next-app-dir/redirect.d.ts.map +1 -0
- package/dist/adapters/next-app-dir/redirect.js +28 -0
- package/dist/adapters/next-app-dir/redirect.mjs +25 -0
- package/dist/adapters/next-app-dir/rethrowNextErrors.d.ts +6 -0
- package/dist/adapters/next-app-dir/rethrowNextErrors.d.ts.map +1 -0
- package/dist/adapters/next-app-dir/rethrowNextErrors.js +23 -0
- package/dist/adapters/next-app-dir/rethrowNextErrors.mjs +21 -0
- package/dist/adapters/next-app-dir.d.ts +4 -0
- package/dist/adapters/next-app-dir.d.ts.map +1 -0
- package/dist/adapters/next-app-dir.js +11 -0
- package/dist/adapters/next-app-dir.mjs +3 -0
- package/dist/adapters/next.js +1 -0
- package/dist/adapters/next.mjs +1 -0
- package/dist/adapters/node-http/content-type/json/getPostBody.js +1 -0
- package/dist/adapters/node-http/content-type/json/getPostBody.mjs +1 -0
- package/dist/adapters/node-http/content-type/json/index.js +1 -0
- package/dist/adapters/node-http/content-type/json/index.mjs +1 -0
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +1 -0
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +1 -0
- package/dist/adapters/standalone.js +1 -0
- package/dist/adapters/standalone.mjs +1 -0
- package/dist/adapters/ws.js +1 -0
- package/dist/adapters/ws.mjs +1 -0
- package/dist/bundle-analysis.json +168 -84
- package/dist/http.js +1 -0
- package/dist/http.mjs +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/rpc.js +1 -0
- package/dist/rpc.mjs +1 -0
- package/dist/shared.js +1 -0
- package/dist/shared.mjs +1 -0
- package/dist/unstable-core-do-not-import/clientish/inference.d.ts +3 -3
- package/dist/unstable-core-do-not-import/clientish/inference.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +1 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +1 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +1 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +1 -0
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/initTRPC.js +2 -4
- package/dist/unstable-core-do-not-import/initTRPC.mjs +2 -4
- package/dist/unstable-core-do-not-import/procedure.d.ts +8 -7
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +9 -21
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.js +5 -6
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +6 -7
- package/dist/unstable-core-do-not-import/router.d.ts +3 -3
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +5 -0
- package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.js +9 -0
- package/dist/unstable-core-do-not-import/utils.mjs +9 -1
- package/dist/unstable-core-do-not-import.js +1 -0
- package/dist/unstable-core-do-not-import.mjs +1 -1
- package/package.json +8 -3
- package/src/adapters/next-app-dir/formDataToObject.ts +36 -0
- package/src/adapters/next-app-dir/nextAppDirCaller.ts +120 -0
- package/src/adapters/next-app-dir/notFound.ts +12 -0
- package/src/adapters/next-app-dir/redirect.ts +27 -0
- package/src/adapters/next-app-dir/rethrowNextErrors.ts +25 -0
- package/src/adapters/next-app-dir.ts +3 -0
- package/src/unstable-core-do-not-import/clientish/inference.ts +9 -5
- package/src/unstable-core-do-not-import/initTRPC.ts +2 -6
- package/src/unstable-core-do-not-import/procedure.ts +10 -17
- package/src/unstable-core-do-not-import/procedureBuilder.ts +34 -49
- package/src/unstable-core-do-not-import/router.ts +4 -3
- package/src/unstable-core-do-not-import/utils.ts +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/adapters/next-app-dir';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/adapters/next-app-dir');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
require('../../unstable-core-do-not-import/utils.js');
|
|
3
4
|
var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
|
|
4
5
|
var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
5
6
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '../../unstable-core-do-not-import/utils.mjs';
|
|
1
2
|
import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
2
3
|
import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
3
4
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var node_stream = require('node:stream');
|
|
4
|
+
require('../../unstable-core-do-not-import/utils.js');
|
|
4
5
|
var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
5
6
|
var batchStreamFormatter = require('../../unstable-core-do-not-import/http/batchStreamFormatter.js');
|
|
6
7
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
+
import '../../unstable-core-do-not-import/utils.mjs';
|
|
2
3
|
import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
3
4
|
import { getBatchStreamFormatter } from '../../unstable-core-do-not-import/http/batchStreamFormatter.mjs';
|
|
4
5
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
require('../../unstable-core-do-not-import/utils.js');
|
|
3
4
|
var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
4
5
|
var batchStreamFormatter = require('../../unstable-core-do-not-import/http/batchStreamFormatter.js');
|
|
5
6
|
var toURL = require('../../unstable-core-do-not-import/http/toURL.js');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '../../unstable-core-do-not-import/utils.mjs';
|
|
1
2
|
import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
2
3
|
import { getBatchStreamFormatter } from '../../unstable-core-do-not-import/http/batchStreamFormatter.mjs';
|
|
3
4
|
import { toURL } from '../../unstable-core-do-not-import/http/toURL.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formDataToObject.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/formDataToObject.ts"],"names":[],"mappings":"AA2BA,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,2BAQlD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */ function set(obj, path, value) {
|
|
4
|
+
if (typeof path === 'string') {
|
|
5
|
+
path = path.split(/[\.\[\]]/).filter(Boolean);
|
|
6
|
+
}
|
|
7
|
+
if (path.length > 1) {
|
|
8
|
+
const p = path.shift();
|
|
9
|
+
const isArrayIndex = /^\d+$/.test(path[0]);
|
|
10
|
+
obj[p] = obj[p] || (isArrayIndex ? [] : {});
|
|
11
|
+
set(obj[p], path, value);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const p1 = path[0];
|
|
15
|
+
if (obj[p1] === undefined) {
|
|
16
|
+
obj[p1] = value;
|
|
17
|
+
} else if (Array.isArray(obj[p1])) {
|
|
18
|
+
obj[p1].push(value);
|
|
19
|
+
} else {
|
|
20
|
+
obj[p1] = [
|
|
21
|
+
obj[p1],
|
|
22
|
+
value
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function formDataToObject(formData) {
|
|
27
|
+
const obj = {};
|
|
28
|
+
for (const [key, value] of formData.entries()){
|
|
29
|
+
set(obj, key, value);
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.formDataToObject = formDataToObject;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */ function set(obj, path, value) {
|
|
2
|
+
if (typeof path === 'string') {
|
|
3
|
+
path = path.split(/[\.\[\]]/).filter(Boolean);
|
|
4
|
+
}
|
|
5
|
+
if (path.length > 1) {
|
|
6
|
+
const p = path.shift();
|
|
7
|
+
const isArrayIndex = /^\d+$/.test(path[0]);
|
|
8
|
+
obj[p] = obj[p] || (isArrayIndex ? [] : {});
|
|
9
|
+
set(obj[p], path, value);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const p1 = path[0];
|
|
13
|
+
if (obj[p1] === undefined) {
|
|
14
|
+
obj[p1] = value;
|
|
15
|
+
} else if (Array.isArray(obj[p1])) {
|
|
16
|
+
obj[p1].push(value);
|
|
17
|
+
} else {
|
|
18
|
+
obj[p1] = [
|
|
19
|
+
obj[p1],
|
|
20
|
+
value
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function formDataToObject(formData) {
|
|
25
|
+
const obj = {};
|
|
26
|
+
for (const [key, value] of formData.entries()){
|
|
27
|
+
set(obj, key, value);
|
|
28
|
+
}
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { formDataToObject };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ErrorHandlerOptions } from '../../unstable-core-do-not-import/procedure';
|
|
2
|
+
import type { CallerOverride } from '../../unstable-core-do-not-import/procedureBuilder';
|
|
3
|
+
import type { MaybePromise, Simplify } from '../../unstable-core-do-not-import/types';
|
|
4
|
+
type ContextCallback<TContext> = object extends TContext ? {
|
|
5
|
+
createContext?: () => MaybePromise<TContext>;
|
|
6
|
+
} : {
|
|
7
|
+
createContext: () => MaybePromise<TContext>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Create a caller that works with Next.js React Server Components & Server Actions
|
|
11
|
+
*/
|
|
12
|
+
export declare function nextAppDirCaller<TContext>(config: Simplify<{
|
|
13
|
+
/**
|
|
14
|
+
* Transform form data to a `Record` before passing it to the procedure
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
normalizeFormData?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Called when an error occurs in the handler
|
|
20
|
+
*/
|
|
21
|
+
onError?: (opts: ErrorHandlerOptions<TContext>) => void;
|
|
22
|
+
} & ContextCallback<TContext>>): CallerOverride<TContext>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=nextAppDirCaller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextAppDirCaller.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/nextAppDirCaller.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAGvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAGzF,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACT,MAAM,yCAAyC,CAAC;AAIjD,KAAK,eAAe,CAAC,QAAQ,IAAI,MAAM,SAAS,QAAQ,GACpD;IACE,aAAa,CAAC,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC;CAC9C,GACD;IACE,aAAa,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC;CAC7C,CAAC;AAEN;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EACvC,MAAM,EAAE,QAAQ,CACd;IACE;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CACzD,GAAG,eAAe,CAAC,QAAQ,CAAC,CAC9B,GACA,cAAc,CAAC,QAAQ,CAAC,CA8E1B"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../../unstable-core-do-not-import/utils.js');
|
|
4
|
+
var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
|
|
5
|
+
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
6
|
+
var formDataToObject = require('./formDataToObject.js');
|
|
7
|
+
var rethrowNextErrors = require('./rethrowNextErrors.js');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create a caller that works with Next.js React Server Components & Server Actions
|
|
11
|
+
*/ function nextAppDirCaller(config) {
|
|
12
|
+
const { normalizeFormData =true } = config;
|
|
13
|
+
const createContext = async ()=>{
|
|
14
|
+
return config?.createContext?.() ?? {};
|
|
15
|
+
};
|
|
16
|
+
return async (opts)=>{
|
|
17
|
+
const ctx = await createContext().catch((cause)=>{
|
|
18
|
+
const error = new TRPCError.TRPCError({
|
|
19
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
20
|
+
message: 'Failed to create context',
|
|
21
|
+
cause
|
|
22
|
+
});
|
|
23
|
+
throw error;
|
|
24
|
+
});
|
|
25
|
+
const handleError = (cause)=>{
|
|
26
|
+
const error = TRPCError.getTRPCErrorFromUnknown(cause);
|
|
27
|
+
config.onError?.({
|
|
28
|
+
ctx,
|
|
29
|
+
error,
|
|
30
|
+
input: opts.args[0],
|
|
31
|
+
path: '',
|
|
32
|
+
type: opts._def.type
|
|
33
|
+
});
|
|
34
|
+
rethrowNextErrors.rethrowNextErrors(error);
|
|
35
|
+
throw error;
|
|
36
|
+
};
|
|
37
|
+
switch(opts._def.type){
|
|
38
|
+
case 'mutation':
|
|
39
|
+
{
|
|
40
|
+
/**
|
|
41
|
+
* When you wrap an action with useFormState, it gets an extra argument as its first argument.
|
|
42
|
+
* The submitted form data is therefore its second argument instead of its first as it would usually be.
|
|
43
|
+
* The new first argument that gets added is the current state of the form.
|
|
44
|
+
* @see https://react.dev/reference/react-dom/hooks/useFormState#my-action-can-no-longer-read-the-submitted-form-data
|
|
45
|
+
*/ let input = opts.args.length === 1 ? opts.args[0] : opts.args[1];
|
|
46
|
+
if (normalizeFormData && input instanceof FormData) {
|
|
47
|
+
input = formDataToObject.formDataToObject(input);
|
|
48
|
+
}
|
|
49
|
+
return await opts.invoke({
|
|
50
|
+
type: opts._def.type,
|
|
51
|
+
ctx,
|
|
52
|
+
getRawInput: async ()=>input,
|
|
53
|
+
path: '',
|
|
54
|
+
input
|
|
55
|
+
}).catch(handleError);
|
|
56
|
+
}
|
|
57
|
+
case 'query':
|
|
58
|
+
{
|
|
59
|
+
const input1 = opts.args[0];
|
|
60
|
+
return await opts.invoke({
|
|
61
|
+
type: opts._def.type,
|
|
62
|
+
ctx,
|
|
63
|
+
getRawInput: async ()=>input1,
|
|
64
|
+
path: '',
|
|
65
|
+
input: input1
|
|
66
|
+
}).catch(handleError);
|
|
67
|
+
}
|
|
68
|
+
default:
|
|
69
|
+
{
|
|
70
|
+
throw new TRPCError.TRPCError({
|
|
71
|
+
code: 'NOT_IMPLEMENTED',
|
|
72
|
+
message: `Not implemented for type ${opts._def.type}`
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.nextAppDirCaller = nextAppDirCaller;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import '../../unstable-core-do-not-import/utils.mjs';
|
|
2
|
+
import { TRPCError, getTRPCErrorFromUnknown } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
+
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
|
+
import { formDataToObject } from './formDataToObject.mjs';
|
|
5
|
+
import { rethrowNextErrors } from './rethrowNextErrors.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Create a caller that works with Next.js React Server Components & Server Actions
|
|
9
|
+
*/ function nextAppDirCaller(config) {
|
|
10
|
+
const { normalizeFormData =true } = config;
|
|
11
|
+
const createContext = async ()=>{
|
|
12
|
+
return config?.createContext?.() ?? {};
|
|
13
|
+
};
|
|
14
|
+
return async (opts)=>{
|
|
15
|
+
const ctx = await createContext().catch((cause)=>{
|
|
16
|
+
const error = new TRPCError({
|
|
17
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
18
|
+
message: 'Failed to create context',
|
|
19
|
+
cause
|
|
20
|
+
});
|
|
21
|
+
throw error;
|
|
22
|
+
});
|
|
23
|
+
const handleError = (cause)=>{
|
|
24
|
+
const error = getTRPCErrorFromUnknown(cause);
|
|
25
|
+
config.onError?.({
|
|
26
|
+
ctx,
|
|
27
|
+
error,
|
|
28
|
+
input: opts.args[0],
|
|
29
|
+
path: '',
|
|
30
|
+
type: opts._def.type
|
|
31
|
+
});
|
|
32
|
+
rethrowNextErrors(error);
|
|
33
|
+
throw error;
|
|
34
|
+
};
|
|
35
|
+
switch(opts._def.type){
|
|
36
|
+
case 'mutation':
|
|
37
|
+
{
|
|
38
|
+
/**
|
|
39
|
+
* When you wrap an action with useFormState, it gets an extra argument as its first argument.
|
|
40
|
+
* The submitted form data is therefore its second argument instead of its first as it would usually be.
|
|
41
|
+
* The new first argument that gets added is the current state of the form.
|
|
42
|
+
* @see https://react.dev/reference/react-dom/hooks/useFormState#my-action-can-no-longer-read-the-submitted-form-data
|
|
43
|
+
*/ let input = opts.args.length === 1 ? opts.args[0] : opts.args[1];
|
|
44
|
+
if (normalizeFormData && input instanceof FormData) {
|
|
45
|
+
input = formDataToObject(input);
|
|
46
|
+
}
|
|
47
|
+
return await opts.invoke({
|
|
48
|
+
type: opts._def.type,
|
|
49
|
+
ctx,
|
|
50
|
+
getRawInput: async ()=>input,
|
|
51
|
+
path: '',
|
|
52
|
+
input
|
|
53
|
+
}).catch(handleError);
|
|
54
|
+
}
|
|
55
|
+
case 'query':
|
|
56
|
+
{
|
|
57
|
+
const input1 = opts.args[0];
|
|
58
|
+
return await opts.invoke({
|
|
59
|
+
type: opts._def.type,
|
|
60
|
+
ctx,
|
|
61
|
+
getRawInput: async ()=>input1,
|
|
62
|
+
path: '',
|
|
63
|
+
input: input1
|
|
64
|
+
}).catch(handleError);
|
|
65
|
+
}
|
|
66
|
+
default:
|
|
67
|
+
{
|
|
68
|
+
throw new TRPCError({
|
|
69
|
+
code: 'NOT_IMPLEMENTED',
|
|
70
|
+
message: `Not implemented for type ${opts._def.type}`
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { nextAppDirCaller };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { notFound as __notFound } from 'next/navigation';
|
|
2
|
+
/**
|
|
3
|
+
* Like `next/navigation`'s `notFound()` but throws a `TRPCError` that later will be handled by Next.js
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare const notFound: typeof __notFound;
|
|
7
|
+
//# sourceMappingURL=notFound.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/notFound.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG9D;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,UAI7B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../../unstable-core-do-not-import/utils.js');
|
|
4
|
+
var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
|
|
5
|
+
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Like `next/navigation`'s `notFound()` but throws a `TRPCError` that later will be handled by Next.js
|
|
9
|
+
* @public
|
|
10
|
+
*/ const notFound = ()=>{
|
|
11
|
+
throw new TRPCError.TRPCError({
|
|
12
|
+
code: 'NOT_FOUND'
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.notFound = notFound;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import '../../unstable-core-do-not-import/utils.mjs';
|
|
2
|
+
import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
+
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Like `next/navigation`'s `notFound()` but throws a `TRPCError` that later will be handled by Next.js
|
|
7
|
+
* @public
|
|
8
|
+
*/ const notFound = ()=>{
|
|
9
|
+
throw new TRPCError({
|
|
10
|
+
code: 'NOT_FOUND'
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { notFound };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { redirect as __redirect } from 'next/navigation';
|
|
2
|
+
import { TRPCError } from '../../@trpc/server';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare class TRPCRedirectError extends TRPCError {
|
|
7
|
+
readonly args: [url: string, type?: import("next/navigation").RedirectType | undefined];
|
|
8
|
+
constructor(...args: Parameters<typeof __redirect>);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Like `next/navigation`'s `redirect()` but throws a `TRPCError` that later will be handled by Next.js
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare const redirect: typeof __redirect;
|
|
15
|
+
//# sourceMappingURL=redirect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/redirect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;IAC9C,SAAgB,IAAI,2EAAC;gBACT,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC;CAUnD;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,UAE7B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../../unstable-core-do-not-import/utils.js');
|
|
4
|
+
var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
|
|
5
|
+
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/ class TRPCRedirectError extends TRPCError.TRPCError {
|
|
10
|
+
constructor(...args){
|
|
11
|
+
const [url] = args;
|
|
12
|
+
super({
|
|
13
|
+
// TODO(?): This should maybe a custom error code
|
|
14
|
+
code: 'UNPROCESSABLE_CONTENT',
|
|
15
|
+
message: `Redirect error to "${url}" that will be handled by Next.js`
|
|
16
|
+
});
|
|
17
|
+
this.args = args;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Like `next/navigation`'s `redirect()` but throws a `TRPCError` that later will be handled by Next.js
|
|
22
|
+
* @public
|
|
23
|
+
*/ const redirect = (...args)=>{
|
|
24
|
+
throw new TRPCRedirectError(...args);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.TRPCRedirectError = TRPCRedirectError;
|
|
28
|
+
exports.redirect = redirect;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import '../../unstable-core-do-not-import/utils.mjs';
|
|
2
|
+
import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
+
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/ class TRPCRedirectError extends TRPCError {
|
|
8
|
+
constructor(...args){
|
|
9
|
+
const [url] = args;
|
|
10
|
+
super({
|
|
11
|
+
// TODO(?): This should maybe a custom error code
|
|
12
|
+
code: 'UNPROCESSABLE_CONTENT',
|
|
13
|
+
message: `Redirect error to "${url}" that will be handled by Next.js`
|
|
14
|
+
});
|
|
15
|
+
this.args = args;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Like `next/navigation`'s `redirect()` but throws a `TRPCError` that later will be handled by Next.js
|
|
20
|
+
* @public
|
|
21
|
+
*/ const redirect = (...args)=>{
|
|
22
|
+
throw new TRPCRedirectError(...args);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { TRPCRedirectError, redirect };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rethrowNextErrors.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/rethrowNextErrors.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;GAEG;AAEH,eAAO,MAAM,iBAAiB,UAAW,SAAS,SAWjD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var notFound = require('next/dist/client/components/not-found');
|
|
4
|
+
var redirect$1 = require('next/dist/client/components/redirect');
|
|
5
|
+
var navigation = require('next/navigation');
|
|
6
|
+
var redirect = require('./redirect.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Rethrow errors that should be handled by Next.js
|
|
10
|
+
*/ const rethrowNextErrors = (error)=>{
|
|
11
|
+
if (error.code === 'NOT_FOUND') {
|
|
12
|
+
navigation.notFound();
|
|
13
|
+
}
|
|
14
|
+
if (error instanceof redirect.TRPCRedirectError) {
|
|
15
|
+
navigation.redirect(...error.args);
|
|
16
|
+
}
|
|
17
|
+
const { cause } = error;
|
|
18
|
+
if (redirect$1.isRedirectError(cause) || notFound.isNotFoundError(cause)) {
|
|
19
|
+
throw error.cause;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.rethrowNextErrors = rethrowNextErrors;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isNotFoundError } from 'next/dist/client/components/not-found';
|
|
2
|
+
import { isRedirectError } from 'next/dist/client/components/redirect';
|
|
3
|
+
import { notFound, redirect } from 'next/navigation';
|
|
4
|
+
import { TRPCRedirectError } from './redirect.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Rethrow errors that should be handled by Next.js
|
|
8
|
+
*/ const rethrowNextErrors = (error)=>{
|
|
9
|
+
if (error.code === 'NOT_FOUND') {
|
|
10
|
+
notFound();
|
|
11
|
+
}
|
|
12
|
+
if (error instanceof TRPCRedirectError) {
|
|
13
|
+
redirect(...error.args);
|
|
14
|
+
}
|
|
15
|
+
const { cause } = error;
|
|
16
|
+
if (isRedirectError(cause) || isNotFoundError(cause)) {
|
|
17
|
+
throw error.cause;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { rethrowNextErrors };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { nextAppDirCaller as experimental_nextAppDirCaller } from './next-app-dir/nextAppDirCaller';
|
|
2
|
+
export { redirect as experimental_redirect } from './next-app-dir/redirect';
|
|
3
|
+
export { notFound as experimental_notFound } from './next-app-dir/notFound';
|
|
4
|
+
//# sourceMappingURL=next-app-dir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-app-dir.d.ts","sourceRoot":"","sources":["../../src/adapters/next-app-dir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,IAAI,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,QAAQ,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,QAAQ,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var nextAppDirCaller = require('./next-app-dir/nextAppDirCaller.js');
|
|
4
|
+
var redirect = require('./next-app-dir/redirect.js');
|
|
5
|
+
var notFound = require('./next-app-dir/notFound.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.experimental_nextAppDirCaller = nextAppDirCaller.nextAppDirCaller;
|
|
10
|
+
exports.experimental_redirect = redirect.redirect;
|
|
11
|
+
exports.experimental_notFound = notFound.notFound;
|
package/dist/adapters/next.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var getErrorShape = require('../unstable-core-do-not-import/error/getErrorShape.js');
|
|
4
4
|
var TRPCError = require('../unstable-core-do-not-import/error/TRPCError.js');
|
|
5
|
+
require('../unstable-core-do-not-import/utils.js');
|
|
5
6
|
require('../unstable-core-do-not-import/rootConfig.js');
|
|
6
7
|
var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
|
|
7
8
|
|
package/dist/adapters/next.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getErrorShape } from '../unstable-core-do-not-import/error/getErrorShape.mjs';
|
|
2
2
|
import { TRPCError } from '../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
+
import '../unstable-core-do-not-import/utils.mjs';
|
|
3
4
|
import '../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
5
|
import { nodeHTTPRequestHandler } from './node-http/nodeHTTPRequestHandler.mjs';
|
|
5
6
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
require('../../../../unstable-core-do-not-import/utils.js');
|
|
3
4
|
var contentType$1 = require('../../../../unstable-core-do-not-import/http/contentType.js');
|
|
4
5
|
require('../../../../unstable-core-do-not-import/rootConfig.js');
|
|
5
6
|
var contentType = require('../../internals/contentType.js');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '../../../../unstable-core-do-not-import/utils.mjs';
|
|
1
2
|
import { getJsonContentTypeInputs } from '../../../../unstable-core-do-not-import/http/contentType.mjs';
|
|
2
3
|
import '../../../../unstable-core-do-not-import/rootConfig.mjs';
|
|
3
4
|
import { createNodeHTTPContentTypeHandler } from '../../internals/contentType.mjs';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
require('../../unstable-core-do-not-import/utils.js');
|
|
3
4
|
var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
4
5
|
var batchStreamFormatter = require('../../unstable-core-do-not-import/http/batchStreamFormatter.js');
|
|
5
6
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '../../unstable-core-do-not-import/utils.mjs';
|
|
1
2
|
import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
2
3
|
import { getBatchStreamFormatter } from '../../unstable-core-do-not-import/http/batchStreamFormatter.mjs';
|
|
3
4
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var http = require('node:http');
|
|
4
|
+
require('../unstable-core-do-not-import/utils.js');
|
|
4
5
|
var toURL = require('../unstable-core-do-not-import/http/toURL.js');
|
|
5
6
|
require('../unstable-core-do-not-import/rootConfig.js');
|
|
6
7
|
var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
|
+
import '../unstable-core-do-not-import/utils.mjs';
|
|
2
3
|
import { toURL } from '../unstable-core-do-not-import/http/toURL.mjs';
|
|
3
4
|
import '../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
5
|
import { nodeHTTPRequestHandler } from './node-http/nodeHTTPRequestHandler.mjs';
|
package/dist/adapters/ws.js
CHANGED
|
@@ -5,6 +5,7 @@ var TRPCError = require('../unstable-core-do-not-import/error/TRPCError.js');
|
|
|
5
5
|
var parseTRPCMessage = require('../unstable-core-do-not-import/rpc/parseTRPCMessage.js');
|
|
6
6
|
var router = require('../unstable-core-do-not-import/router.js');
|
|
7
7
|
var transformer = require('../unstable-core-do-not-import/transformer.js');
|
|
8
|
+
require('../unstable-core-do-not-import/utils.js');
|
|
8
9
|
require('../unstable-core-do-not-import/rootConfig.js');
|
|
9
10
|
var observable = require('../observable/observable.js');
|
|
10
11
|
|
package/dist/adapters/ws.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { TRPCError, getTRPCErrorFromUnknown } from '../unstable-core-do-not-impo
|
|
|
3
3
|
import { parseTRPCMessage } from '../unstable-core-do-not-import/rpc/parseTRPCMessage.mjs';
|
|
4
4
|
import { callProcedure } from '../unstable-core-do-not-import/router.mjs';
|
|
5
5
|
import { transformTRPCResponse } from '../unstable-core-do-not-import/transformer.mjs';
|
|
6
|
+
import '../unstable-core-do-not-import/utils.mjs';
|
|
6
7
|
import '../unstable-core-do-not-import/rootConfig.mjs';
|
|
7
8
|
import { isObservable } from '../observable/observable.mjs';
|
|
8
9
|
|