@trpc/server 11.4.1 → 11.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/aws-lambda/index.cjs +49 -42
- package/dist/adapters/aws-lambda/index.mjs +47 -40
- package/dist/adapters/aws-lambda/index.mjs.map +1 -1
- package/dist/adapters/express.cjs +14 -15
- package/dist/adapters/express.mjs +14 -15
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/fastify/index.cjs +27 -28
- package/dist/adapters/fastify/index.mjs +27 -28
- package/dist/adapters/fastify/index.mjs.map +1 -1
- package/dist/adapters/fetch/index.cjs +18 -19
- package/dist/adapters/fetch/index.mjs +18 -19
- package/dist/adapters/fetch/index.mjs.map +1 -1
- package/dist/adapters/next-app-dir.cjs +57 -53
- package/dist/adapters/next-app-dir.mjs +15 -11
- package/dist/adapters/next-app-dir.mjs.map +1 -1
- package/dist/adapters/next.cjs +14 -15
- package/dist/adapters/next.mjs +14 -15
- package/dist/adapters/next.mjs.map +1 -1
- package/dist/adapters/node-http/index.cjs +8 -8
- package/dist/adapters/node-http/index.mjs +8 -8
- package/dist/adapters/standalone.cjs +17 -17
- package/dist/adapters/standalone.mjs +16 -16
- package/dist/adapters/standalone.mjs.map +1 -1
- package/dist/adapters/ws.cjs +10 -10
- package/dist/adapters/ws.mjs +10 -10
- package/dist/getErrorShape-DKiEF6Zc.cjs +339 -0
- package/dist/getErrorShape-Uhlrl4Bk.mjs +263 -0
- package/dist/getErrorShape-Uhlrl4Bk.mjs.map +1 -0
- package/dist/http.cjs +5 -5
- package/dist/http.mjs +5 -5
- package/dist/index.cjs +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{initTRPC-DjEpHmY2.cjs → initTRPC-IT4M4lu3.cjs} +83 -64
- package/dist/{initTRPC-COaJMShh.mjs → initTRPC-IT_6ZYJd.mjs} +84 -65
- package/dist/initTRPC-IT_6ZYJd.mjs.map +1 -0
- package/dist/{node-http-BUQnHuGI.mjs → node-http-Du8akt-R.mjs} +26 -23
- package/dist/{node-http-BUQnHuGI.mjs.map → node-http-Du8akt-R.mjs.map} +1 -1
- package/dist/{node-http-BPR68yI4.cjs → node-http-kIQEhZUH.cjs} +25 -22
- package/dist/observable/index.cjs +2 -2
- package/dist/observable/index.mjs +2 -2
- package/dist/{observable-BwdrSFZU.cjs → observable-B1Nk6r1H.cjs} +7 -4
- package/dist/{observable-C6qq2Ydk.cjs → observable-BVzLuBs6.cjs} +19 -7
- package/dist/{observable-CFXA_tyK.mjs → observable-CUiPknO-.mjs} +20 -8
- package/dist/{observable-CFXA_tyK.mjs.map → observable-CUiPknO-.mjs.map} +1 -1
- package/dist/{observable-B1orLHHI.mjs → observable-UMO3vUa_.mjs} +8 -5
- package/dist/{observable-B1orLHHI.mjs.map → observable-UMO3vUa_.mjs.map} +1 -1
- package/dist/{parseTRPCMessage-CNyYMSRB.mjs → parseTRPCMessage-ByIHyFRz.mjs} +2 -2
- package/dist/{parseTRPCMessage-CNyYMSRB.mjs.map → parseTRPCMessage-ByIHyFRz.mjs.map} +1 -1
- package/dist/{parseTRPCMessage-ByQWigsq.cjs → parseTRPCMessage-snNQop7N.cjs} +1 -1
- package/dist/{resolveResponse-B2CuaT_1.cjs → resolveResponse-CVGbakBm.cjs} +664 -405
- package/dist/{resolveResponse-DPbYgJDD.mjs → resolveResponse-CzlbRpCI.mjs} +660 -389
- package/dist/resolveResponse-CzlbRpCI.mjs.map +1 -0
- package/dist/rpc.cjs +2 -2
- package/dist/rpc.mjs +2 -2
- package/dist/shared.cjs +2 -2
- package/dist/shared.mjs +2 -2
- package/dist/{tracked-Dl9sBZxY.cjs → tracked-HoF8L_mq.cjs} +30 -42
- package/dist/{tracked-GEWPoL0C.mjs → tracked-gU3ttYjg.mjs} +31 -43
- package/dist/{tracked-GEWPoL0C.mjs.map → tracked-gU3ttYjg.mjs.map} +1 -1
- package/dist/unstable-core-do-not-import.cjs +7 -7
- package/dist/unstable-core-do-not-import.mjs +7 -7
- package/dist/{utils-BHZJcBRv.mjs → utils-DdbbrDku.mjs} +1 -1
- package/dist/{utils-BHZJcBRv.mjs.map → utils-DdbbrDku.mjs.map} +1 -1
- package/dist/{ws-C2nEUNk_.cjs → ws-BhrWsMpl.cjs} +37 -26
- package/dist/{ws-eIVIMTrw.mjs → ws-Bn5rkP_I.mjs} +37 -26
- package/dist/{ws-eIVIMTrw.mjs.map → ws-Bn5rkP_I.mjs.map} +1 -1
- package/package.json +2 -2
- package/dist/getErrorShape-CsikfkAc.cjs +0 -201
- package/dist/getErrorShape-DyYil4aT.mjs +0 -149
- package/dist/getErrorShape-DyYil4aT.mjs.map +0 -1
- package/dist/initTRPC-COaJMShh.mjs.map +0 -1
- package/dist/resolveResponse-DPbYgJDD.mjs.map +0 -1
- /package/dist/{utils-DVO6HZiR.cjs → utils-BhNVZA-c.cjs} +0 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
|
+
key = keys[i];
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
+
value: mod,
|
|
23
|
+
enumerable: true
|
|
24
|
+
}) : target, mod));
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
const require_utils = require('./utils-BhNVZA-c.cjs');
|
|
28
|
+
|
|
29
|
+
//#region src/unstable-core-do-not-import/createProxy.ts
|
|
30
|
+
const noop = () => {};
|
|
31
|
+
const freezeIfAvailable = (obj) => {
|
|
32
|
+
if (Object.freeze) Object.freeze(obj);
|
|
33
|
+
};
|
|
34
|
+
function createInnerProxy(callback, path, memo) {
|
|
35
|
+
var _memo$cacheKey;
|
|
36
|
+
const cacheKey = path.join(".");
|
|
37
|
+
(_memo$cacheKey = memo[cacheKey]) !== null && _memo$cacheKey !== void 0 || (memo[cacheKey] = new Proxy(noop, {
|
|
38
|
+
get(_obj, key) {
|
|
39
|
+
if (typeof key !== "string" || key === "then") return void 0;
|
|
40
|
+
return createInnerProxy(callback, [...path, key], memo);
|
|
41
|
+
},
|
|
42
|
+
apply(_1, _2, args) {
|
|
43
|
+
const lastOfPath = path[path.length - 1];
|
|
44
|
+
let opts = {
|
|
45
|
+
args,
|
|
46
|
+
path
|
|
47
|
+
};
|
|
48
|
+
if (lastOfPath === "call") opts = {
|
|
49
|
+
args: args.length >= 2 ? [args[1]] : [],
|
|
50
|
+
path: path.slice(0, -1)
|
|
51
|
+
};
|
|
52
|
+
else if (lastOfPath === "apply") opts = {
|
|
53
|
+
args: args.length >= 2 ? args[1] : [],
|
|
54
|
+
path: path.slice(0, -1)
|
|
55
|
+
};
|
|
56
|
+
freezeIfAvailable(opts.args);
|
|
57
|
+
freezeIfAvailable(opts.path);
|
|
58
|
+
return callback(opts);
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
return memo[cacheKey];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Creates a proxy that calls the callback with the path and arguments
|
|
65
|
+
*
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
const createRecursiveProxy = (callback) => createInnerProxy(callback, [], Object.create(null));
|
|
69
|
+
/**
|
|
70
|
+
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
71
|
+
*
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
const createFlatProxy = (callback) => {
|
|
75
|
+
return new Proxy(noop, { get(_obj, name) {
|
|
76
|
+
if (name === "then") return void 0;
|
|
77
|
+
return callback(name);
|
|
78
|
+
} });
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/unstable-core-do-not-import/http/getHTTPStatusCode.ts
|
|
83
|
+
const JSONRPC2_TO_HTTP_CODE = {
|
|
84
|
+
PARSE_ERROR: 400,
|
|
85
|
+
BAD_REQUEST: 400,
|
|
86
|
+
UNAUTHORIZED: 401,
|
|
87
|
+
PAYMENT_REQUIRED: 402,
|
|
88
|
+
FORBIDDEN: 403,
|
|
89
|
+
NOT_FOUND: 404,
|
|
90
|
+
METHOD_NOT_SUPPORTED: 405,
|
|
91
|
+
TIMEOUT: 408,
|
|
92
|
+
CONFLICT: 409,
|
|
93
|
+
PRECONDITION_FAILED: 412,
|
|
94
|
+
PAYLOAD_TOO_LARGE: 413,
|
|
95
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
96
|
+
UNPROCESSABLE_CONTENT: 422,
|
|
97
|
+
TOO_MANY_REQUESTS: 429,
|
|
98
|
+
CLIENT_CLOSED_REQUEST: 499,
|
|
99
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
100
|
+
NOT_IMPLEMENTED: 501,
|
|
101
|
+
BAD_GATEWAY: 502,
|
|
102
|
+
SERVICE_UNAVAILABLE: 503,
|
|
103
|
+
GATEWAY_TIMEOUT: 504
|
|
104
|
+
};
|
|
105
|
+
const HTTP_CODE_TO_JSONRPC2 = {
|
|
106
|
+
400: "BAD_REQUEST",
|
|
107
|
+
401: "UNAUTHORIZED",
|
|
108
|
+
402: "PAYMENT_REQUIRED",
|
|
109
|
+
403: "FORBIDDEN",
|
|
110
|
+
404: "NOT_FOUND",
|
|
111
|
+
405: "METHOD_NOT_SUPPORTED",
|
|
112
|
+
408: "TIMEOUT",
|
|
113
|
+
409: "CONFLICT",
|
|
114
|
+
412: "PRECONDITION_FAILED",
|
|
115
|
+
413: "PAYLOAD_TOO_LARGE",
|
|
116
|
+
415: "UNSUPPORTED_MEDIA_TYPE",
|
|
117
|
+
422: "UNPROCESSABLE_CONTENT",
|
|
118
|
+
429: "TOO_MANY_REQUESTS",
|
|
119
|
+
499: "CLIENT_CLOSED_REQUEST",
|
|
120
|
+
500: "INTERNAL_SERVER_ERROR",
|
|
121
|
+
501: "NOT_IMPLEMENTED",
|
|
122
|
+
502: "BAD_GATEWAY",
|
|
123
|
+
503: "SERVICE_UNAVAILABLE",
|
|
124
|
+
504: "GATEWAY_TIMEOUT"
|
|
125
|
+
};
|
|
126
|
+
function getStatusCodeFromKey(code) {
|
|
127
|
+
var _JSONRPC2_TO_HTTP_COD;
|
|
128
|
+
return (_JSONRPC2_TO_HTTP_COD = JSONRPC2_TO_HTTP_CODE[code]) !== null && _JSONRPC2_TO_HTTP_COD !== void 0 ? _JSONRPC2_TO_HTTP_COD : 500;
|
|
129
|
+
}
|
|
130
|
+
function getStatusKeyFromCode(code) {
|
|
131
|
+
var _HTTP_CODE_TO_JSONRPC;
|
|
132
|
+
return (_HTTP_CODE_TO_JSONRPC = HTTP_CODE_TO_JSONRPC2[code]) !== null && _HTTP_CODE_TO_JSONRPC !== void 0 ? _HTTP_CODE_TO_JSONRPC : "INTERNAL_SERVER_ERROR";
|
|
133
|
+
}
|
|
134
|
+
function getHTTPStatusCode(json) {
|
|
135
|
+
const arr = Array.isArray(json) ? json : [json];
|
|
136
|
+
const httpStatuses = new Set(arr.map((res) => {
|
|
137
|
+
if ("error" in res && require_utils.isObject(res.error.data)) {
|
|
138
|
+
var _res$error$data;
|
|
139
|
+
if (typeof ((_res$error$data = res.error.data) === null || _res$error$data === void 0 ? void 0 : _res$error$data["httpStatus"]) === "number") return res.error.data["httpStatus"];
|
|
140
|
+
const code = require_utils.TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
|
|
141
|
+
return getStatusCodeFromKey(code);
|
|
142
|
+
}
|
|
143
|
+
return 200;
|
|
144
|
+
}));
|
|
145
|
+
if (httpStatuses.size !== 1) return 207;
|
|
146
|
+
const httpStatus = httpStatuses.values().next().value;
|
|
147
|
+
return httpStatus;
|
|
148
|
+
}
|
|
149
|
+
function getHTTPStatusCodeFromError(error) {
|
|
150
|
+
return getStatusCodeFromKey(error.code);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js
|
|
155
|
+
var require_typeof = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
|
|
156
|
+
function _typeof$2(o) {
|
|
157
|
+
"@babel/helpers - typeof";
|
|
158
|
+
return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
159
|
+
return typeof o$1;
|
|
160
|
+
} : function(o$1) {
|
|
161
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
162
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
|
|
163
|
+
}
|
|
164
|
+
module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
165
|
+
} });
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js
|
|
169
|
+
var require_toPrimitive = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
|
|
170
|
+
var _typeof$1 = require_typeof()["default"];
|
|
171
|
+
function toPrimitive$1(t, r) {
|
|
172
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
173
|
+
var e = t[Symbol.toPrimitive];
|
|
174
|
+
if (void 0 !== e) {
|
|
175
|
+
var i = e.call(t, r || "default");
|
|
176
|
+
if ("object" != _typeof$1(i)) return i;
|
|
177
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
178
|
+
}
|
|
179
|
+
return ("string" === r ? String : Number)(t);
|
|
180
|
+
}
|
|
181
|
+
module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
182
|
+
} });
|
|
183
|
+
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js
|
|
186
|
+
var require_toPropertyKey = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
|
|
187
|
+
var _typeof = require_typeof()["default"];
|
|
188
|
+
var toPrimitive = require_toPrimitive();
|
|
189
|
+
function toPropertyKey$1(t) {
|
|
190
|
+
var i = toPrimitive(t, "string");
|
|
191
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
192
|
+
}
|
|
193
|
+
module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
194
|
+
} });
|
|
195
|
+
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js
|
|
198
|
+
var require_defineProperty = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
|
|
199
|
+
var toPropertyKey = require_toPropertyKey();
|
|
200
|
+
function _defineProperty(e, r, t) {
|
|
201
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
202
|
+
value: t,
|
|
203
|
+
enumerable: !0,
|
|
204
|
+
configurable: !0,
|
|
205
|
+
writable: !0
|
|
206
|
+
}) : e[r] = t, e;
|
|
207
|
+
}
|
|
208
|
+
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
209
|
+
} });
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js
|
|
213
|
+
var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
|
|
214
|
+
var defineProperty = require_defineProperty();
|
|
215
|
+
function ownKeys(e, r) {
|
|
216
|
+
var t = Object.keys(e);
|
|
217
|
+
if (Object.getOwnPropertySymbols) {
|
|
218
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
219
|
+
r && (o = o.filter(function(r$1) {
|
|
220
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
221
|
+
})), t.push.apply(t, o);
|
|
222
|
+
}
|
|
223
|
+
return t;
|
|
224
|
+
}
|
|
225
|
+
function _objectSpread2(e) {
|
|
226
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
227
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
228
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
229
|
+
defineProperty(e, r$1, t[r$1]);
|
|
230
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
231
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
return e;
|
|
235
|
+
}
|
|
236
|
+
module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
237
|
+
} });
|
|
238
|
+
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/unstable-core-do-not-import/error/getErrorShape.ts
|
|
241
|
+
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
|
242
|
+
/**
|
|
243
|
+
* @internal
|
|
244
|
+
*/
|
|
245
|
+
function getErrorShape(opts) {
|
|
246
|
+
const { path, error, config } = opts;
|
|
247
|
+
const { code } = opts.error;
|
|
248
|
+
const shape = {
|
|
249
|
+
message: error.message,
|
|
250
|
+
code: require_utils.TRPC_ERROR_CODES_BY_KEY[code],
|
|
251
|
+
data: {
|
|
252
|
+
code,
|
|
253
|
+
httpStatus: getHTTPStatusCodeFromError(error)
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
if (config.isDev && typeof opts.error.stack === "string") shape.data.stack = opts.error.stack;
|
|
257
|
+
if (typeof path === "string") shape.data.path = path;
|
|
258
|
+
return config.errorFormatter((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, { shape }));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
//#endregion
|
|
262
|
+
Object.defineProperty(exports, 'HTTP_CODE_TO_JSONRPC2', {
|
|
263
|
+
enumerable: true,
|
|
264
|
+
get: function () {
|
|
265
|
+
return HTTP_CODE_TO_JSONRPC2;
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
Object.defineProperty(exports, 'JSONRPC2_TO_HTTP_CODE', {
|
|
269
|
+
enumerable: true,
|
|
270
|
+
get: function () {
|
|
271
|
+
return JSONRPC2_TO_HTTP_CODE;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
Object.defineProperty(exports, '__commonJS', {
|
|
275
|
+
enumerable: true,
|
|
276
|
+
get: function () {
|
|
277
|
+
return __commonJS;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
Object.defineProperty(exports, '__toESM', {
|
|
281
|
+
enumerable: true,
|
|
282
|
+
get: function () {
|
|
283
|
+
return __toESM;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
Object.defineProperty(exports, 'createFlatProxy', {
|
|
287
|
+
enumerable: true,
|
|
288
|
+
get: function () {
|
|
289
|
+
return createFlatProxy;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
Object.defineProperty(exports, 'createRecursiveProxy', {
|
|
293
|
+
enumerable: true,
|
|
294
|
+
get: function () {
|
|
295
|
+
return createRecursiveProxy;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
Object.defineProperty(exports, 'getErrorShape', {
|
|
299
|
+
enumerable: true,
|
|
300
|
+
get: function () {
|
|
301
|
+
return getErrorShape;
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
Object.defineProperty(exports, 'getHTTPStatusCode', {
|
|
305
|
+
enumerable: true,
|
|
306
|
+
get: function () {
|
|
307
|
+
return getHTTPStatusCode;
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
Object.defineProperty(exports, 'getHTTPStatusCodeFromError', {
|
|
311
|
+
enumerable: true,
|
|
312
|
+
get: function () {
|
|
313
|
+
return getHTTPStatusCodeFromError;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
Object.defineProperty(exports, 'getStatusCodeFromKey', {
|
|
317
|
+
enumerable: true,
|
|
318
|
+
get: function () {
|
|
319
|
+
return getStatusCodeFromKey;
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
Object.defineProperty(exports, 'getStatusKeyFromCode', {
|
|
323
|
+
enumerable: true,
|
|
324
|
+
get: function () {
|
|
325
|
+
return getStatusKeyFromCode;
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
Object.defineProperty(exports, 'require_defineProperty', {
|
|
329
|
+
enumerable: true,
|
|
330
|
+
get: function () {
|
|
331
|
+
return require_defineProperty;
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
Object.defineProperty(exports, 'require_objectSpread2', {
|
|
335
|
+
enumerable: true,
|
|
336
|
+
get: function () {
|
|
337
|
+
return require_objectSpread2;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { TRPC_ERROR_CODES_BY_KEY, TRPC_ERROR_CODES_BY_NUMBER, isObject } from "./utils-DdbbrDku.mjs";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __commonJS = (cb, mod) => function() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/unstable-core-do-not-import/createProxy.ts
|
|
30
|
+
const noop = () => {};
|
|
31
|
+
const freezeIfAvailable = (obj) => {
|
|
32
|
+
if (Object.freeze) Object.freeze(obj);
|
|
33
|
+
};
|
|
34
|
+
function createInnerProxy(callback, path, memo) {
|
|
35
|
+
var _memo$cacheKey;
|
|
36
|
+
const cacheKey = path.join(".");
|
|
37
|
+
(_memo$cacheKey = memo[cacheKey]) !== null && _memo$cacheKey !== void 0 || (memo[cacheKey] = new Proxy(noop, {
|
|
38
|
+
get(_obj, key) {
|
|
39
|
+
if (typeof key !== "string" || key === "then") return void 0;
|
|
40
|
+
return createInnerProxy(callback, [...path, key], memo);
|
|
41
|
+
},
|
|
42
|
+
apply(_1, _2, args) {
|
|
43
|
+
const lastOfPath = path[path.length - 1];
|
|
44
|
+
let opts = {
|
|
45
|
+
args,
|
|
46
|
+
path
|
|
47
|
+
};
|
|
48
|
+
if (lastOfPath === "call") opts = {
|
|
49
|
+
args: args.length >= 2 ? [args[1]] : [],
|
|
50
|
+
path: path.slice(0, -1)
|
|
51
|
+
};
|
|
52
|
+
else if (lastOfPath === "apply") opts = {
|
|
53
|
+
args: args.length >= 2 ? args[1] : [],
|
|
54
|
+
path: path.slice(0, -1)
|
|
55
|
+
};
|
|
56
|
+
freezeIfAvailable(opts.args);
|
|
57
|
+
freezeIfAvailable(opts.path);
|
|
58
|
+
return callback(opts);
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
return memo[cacheKey];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Creates a proxy that calls the callback with the path and arguments
|
|
65
|
+
*
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
const createRecursiveProxy = (callback) => createInnerProxy(callback, [], Object.create(null));
|
|
69
|
+
/**
|
|
70
|
+
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
71
|
+
*
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
const createFlatProxy = (callback) => {
|
|
75
|
+
return new Proxy(noop, { get(_obj, name) {
|
|
76
|
+
if (name === "then") return void 0;
|
|
77
|
+
return callback(name);
|
|
78
|
+
} });
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/unstable-core-do-not-import/http/getHTTPStatusCode.ts
|
|
83
|
+
const JSONRPC2_TO_HTTP_CODE = {
|
|
84
|
+
PARSE_ERROR: 400,
|
|
85
|
+
BAD_REQUEST: 400,
|
|
86
|
+
UNAUTHORIZED: 401,
|
|
87
|
+
PAYMENT_REQUIRED: 402,
|
|
88
|
+
FORBIDDEN: 403,
|
|
89
|
+
NOT_FOUND: 404,
|
|
90
|
+
METHOD_NOT_SUPPORTED: 405,
|
|
91
|
+
TIMEOUT: 408,
|
|
92
|
+
CONFLICT: 409,
|
|
93
|
+
PRECONDITION_FAILED: 412,
|
|
94
|
+
PAYLOAD_TOO_LARGE: 413,
|
|
95
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
96
|
+
UNPROCESSABLE_CONTENT: 422,
|
|
97
|
+
TOO_MANY_REQUESTS: 429,
|
|
98
|
+
CLIENT_CLOSED_REQUEST: 499,
|
|
99
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
100
|
+
NOT_IMPLEMENTED: 501,
|
|
101
|
+
BAD_GATEWAY: 502,
|
|
102
|
+
SERVICE_UNAVAILABLE: 503,
|
|
103
|
+
GATEWAY_TIMEOUT: 504
|
|
104
|
+
};
|
|
105
|
+
const HTTP_CODE_TO_JSONRPC2 = {
|
|
106
|
+
400: "BAD_REQUEST",
|
|
107
|
+
401: "UNAUTHORIZED",
|
|
108
|
+
402: "PAYMENT_REQUIRED",
|
|
109
|
+
403: "FORBIDDEN",
|
|
110
|
+
404: "NOT_FOUND",
|
|
111
|
+
405: "METHOD_NOT_SUPPORTED",
|
|
112
|
+
408: "TIMEOUT",
|
|
113
|
+
409: "CONFLICT",
|
|
114
|
+
412: "PRECONDITION_FAILED",
|
|
115
|
+
413: "PAYLOAD_TOO_LARGE",
|
|
116
|
+
415: "UNSUPPORTED_MEDIA_TYPE",
|
|
117
|
+
422: "UNPROCESSABLE_CONTENT",
|
|
118
|
+
429: "TOO_MANY_REQUESTS",
|
|
119
|
+
499: "CLIENT_CLOSED_REQUEST",
|
|
120
|
+
500: "INTERNAL_SERVER_ERROR",
|
|
121
|
+
501: "NOT_IMPLEMENTED",
|
|
122
|
+
502: "BAD_GATEWAY",
|
|
123
|
+
503: "SERVICE_UNAVAILABLE",
|
|
124
|
+
504: "GATEWAY_TIMEOUT"
|
|
125
|
+
};
|
|
126
|
+
function getStatusCodeFromKey(code) {
|
|
127
|
+
var _JSONRPC2_TO_HTTP_COD;
|
|
128
|
+
return (_JSONRPC2_TO_HTTP_COD = JSONRPC2_TO_HTTP_CODE[code]) !== null && _JSONRPC2_TO_HTTP_COD !== void 0 ? _JSONRPC2_TO_HTTP_COD : 500;
|
|
129
|
+
}
|
|
130
|
+
function getStatusKeyFromCode(code) {
|
|
131
|
+
var _HTTP_CODE_TO_JSONRPC;
|
|
132
|
+
return (_HTTP_CODE_TO_JSONRPC = HTTP_CODE_TO_JSONRPC2[code]) !== null && _HTTP_CODE_TO_JSONRPC !== void 0 ? _HTTP_CODE_TO_JSONRPC : "INTERNAL_SERVER_ERROR";
|
|
133
|
+
}
|
|
134
|
+
function getHTTPStatusCode(json) {
|
|
135
|
+
const arr = Array.isArray(json) ? json : [json];
|
|
136
|
+
const httpStatuses = new Set(arr.map((res) => {
|
|
137
|
+
if ("error" in res && isObject(res.error.data)) {
|
|
138
|
+
var _res$error$data;
|
|
139
|
+
if (typeof ((_res$error$data = res.error.data) === null || _res$error$data === void 0 ? void 0 : _res$error$data["httpStatus"]) === "number") return res.error.data["httpStatus"];
|
|
140
|
+
const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
|
|
141
|
+
return getStatusCodeFromKey(code);
|
|
142
|
+
}
|
|
143
|
+
return 200;
|
|
144
|
+
}));
|
|
145
|
+
if (httpStatuses.size !== 1) return 207;
|
|
146
|
+
const httpStatus = httpStatuses.values().next().value;
|
|
147
|
+
return httpStatus;
|
|
148
|
+
}
|
|
149
|
+
function getHTTPStatusCodeFromError(error) {
|
|
150
|
+
return getStatusCodeFromKey(error.code);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js
|
|
155
|
+
var require_typeof = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
|
|
156
|
+
function _typeof$2(o) {
|
|
157
|
+
"@babel/helpers - typeof";
|
|
158
|
+
return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
159
|
+
return typeof o$1;
|
|
160
|
+
} : function(o$1) {
|
|
161
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
162
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
|
|
163
|
+
}
|
|
164
|
+
module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
165
|
+
} });
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js
|
|
169
|
+
var require_toPrimitive = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
|
|
170
|
+
var _typeof$1 = require_typeof()["default"];
|
|
171
|
+
function toPrimitive$1(t, r) {
|
|
172
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
173
|
+
var e = t[Symbol.toPrimitive];
|
|
174
|
+
if (void 0 !== e) {
|
|
175
|
+
var i = e.call(t, r || "default");
|
|
176
|
+
if ("object" != _typeof$1(i)) return i;
|
|
177
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
178
|
+
}
|
|
179
|
+
return ("string" === r ? String : Number)(t);
|
|
180
|
+
}
|
|
181
|
+
module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
182
|
+
} });
|
|
183
|
+
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js
|
|
186
|
+
var require_toPropertyKey = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
|
|
187
|
+
var _typeof = require_typeof()["default"];
|
|
188
|
+
var toPrimitive = require_toPrimitive();
|
|
189
|
+
function toPropertyKey$1(t) {
|
|
190
|
+
var i = toPrimitive(t, "string");
|
|
191
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
192
|
+
}
|
|
193
|
+
module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
194
|
+
} });
|
|
195
|
+
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js
|
|
198
|
+
var require_defineProperty = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
|
|
199
|
+
var toPropertyKey = require_toPropertyKey();
|
|
200
|
+
function _defineProperty(e, r, t) {
|
|
201
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
202
|
+
value: t,
|
|
203
|
+
enumerable: !0,
|
|
204
|
+
configurable: !0,
|
|
205
|
+
writable: !0
|
|
206
|
+
}) : e[r] = t, e;
|
|
207
|
+
}
|
|
208
|
+
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
209
|
+
} });
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js
|
|
213
|
+
var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
|
|
214
|
+
var defineProperty = require_defineProperty();
|
|
215
|
+
function ownKeys(e, r) {
|
|
216
|
+
var t = Object.keys(e);
|
|
217
|
+
if (Object.getOwnPropertySymbols) {
|
|
218
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
219
|
+
r && (o = o.filter(function(r$1) {
|
|
220
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
221
|
+
})), t.push.apply(t, o);
|
|
222
|
+
}
|
|
223
|
+
return t;
|
|
224
|
+
}
|
|
225
|
+
function _objectSpread2(e) {
|
|
226
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
227
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
228
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
229
|
+
defineProperty(e, r$1, t[r$1]);
|
|
230
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
231
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
return e;
|
|
235
|
+
}
|
|
236
|
+
module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
237
|
+
} });
|
|
238
|
+
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/unstable-core-do-not-import/error/getErrorShape.ts
|
|
241
|
+
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
|
242
|
+
/**
|
|
243
|
+
* @internal
|
|
244
|
+
*/
|
|
245
|
+
function getErrorShape(opts) {
|
|
246
|
+
const { path, error, config } = opts;
|
|
247
|
+
const { code } = opts.error;
|
|
248
|
+
const shape = {
|
|
249
|
+
message: error.message,
|
|
250
|
+
code: TRPC_ERROR_CODES_BY_KEY[code],
|
|
251
|
+
data: {
|
|
252
|
+
code,
|
|
253
|
+
httpStatus: getHTTPStatusCodeFromError(error)
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
if (config.isDev && typeof opts.error.stack === "string") shape.data.stack = opts.error.stack;
|
|
257
|
+
if (typeof path === "string") shape.data.path = path;
|
|
258
|
+
return config.errorFormatter((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, { shape }));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
//#endregion
|
|
262
|
+
export { HTTP_CODE_TO_JSONRPC2, JSONRPC2_TO_HTTP_CODE, __commonJS, __toESM, createFlatProxy, createRecursiveProxy, getErrorShape, getHTTPStatusCode, getHTTPStatusCodeFromError, getStatusCodeFromKey, getStatusKeyFromCode, require_defineProperty, require_objectSpread2 };
|
|
263
|
+
//# sourceMappingURL=getErrorShape-Uhlrl4Bk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getErrorShape-Uhlrl4Bk.mjs","names":["obj: object","callback: ProxyCallback","path: readonly string[]","memo: Record<string, unknown>","callback: (path: keyof TFaux) => any","JSONRPC2_TO_HTTP_CODE: Record<\n keyof typeof TRPC_ERROR_CODES_BY_KEY,\n number\n>","HTTP_CODE_TO_JSONRPC2: InvertKeyValue<\n typeof JSONRPC2_TO_HTTP_CODE\n>","code: keyof typeof TRPC_ERROR_CODES_BY_KEY","code: keyof typeof HTTP_CODE_TO_JSONRPC2","json: TRPCResponse | TRPCResponse[]","error: TRPCError","_typeof","o","_typeof","toPrimitive","toPropertyKey","r","opts: {\n config: RootConfig<TRoot>;\n error: TRPCError;\n type: ProcedureType | 'unknown';\n path: string | undefined;\n input: unknown;\n ctx: TRoot['ctx'] | undefined;\n}","shape: DefaultErrorShape"],"sources":["../src/unstable-core-do-not-import/createProxy.ts","../src/unstable-core-do-not-import/http/getHTTPStatusCode.ts","../../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js","../../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js","../../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js","../../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js","../../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js","../src/unstable-core-do-not-import/error/getErrorShape.ts"],"sourcesContent":["interface ProxyCallbackOptions {\n path: readonly string[];\n args: readonly unknown[];\n}\ntype ProxyCallback = (opts: ProxyCallbackOptions) => unknown;\n\nconst noop = () => {\n // noop\n};\n\nconst freezeIfAvailable = (obj: object) => {\n if (Object.freeze) {\n Object.freeze(obj);\n }\n};\n\nfunction createInnerProxy(\n callback: ProxyCallback,\n path: readonly string[],\n memo: Record<string, unknown>,\n) {\n const cacheKey = path.join('.');\n\n memo[cacheKey] ??= new Proxy(noop, {\n get(_obj, key) {\n if (typeof key !== 'string' || key === 'then') {\n // special case for if the proxy is accidentally treated\n // like a PromiseLike (like in `Promise.resolve(proxy)`)\n return undefined;\n }\n return createInnerProxy(callback, [...path, key], memo);\n },\n apply(_1, _2, args) {\n const lastOfPath = path[path.length - 1];\n\n let opts = { args, path };\n // special handling for e.g. `trpc.hello.call(this, 'there')` and `trpc.hello.apply(this, ['there'])\n if (lastOfPath === 'call') {\n opts = {\n args: args.length >= 2 ? [args[1]] : [],\n path: path.slice(0, -1),\n };\n } else if (lastOfPath === 'apply') {\n opts = {\n args: args.length >= 2 ? args[1] : [],\n path: path.slice(0, -1),\n };\n }\n freezeIfAvailable(opts.args);\n freezeIfAvailable(opts.path);\n return callback(opts);\n },\n });\n\n return memo[cacheKey];\n}\n\n/**\n * Creates a proxy that calls the callback with the path and arguments\n *\n * @internal\n */\nexport const createRecursiveProxy = <TFaux = unknown>(\n callback: ProxyCallback,\n): TFaux => createInnerProxy(callback, [], Object.create(null)) as TFaux;\n\n/**\n * Used in place of `new Proxy` where each handler will map 1 level deep to another value.\n *\n * @internal\n */\nexport const createFlatProxy = <TFaux>(\n callback: (path: keyof TFaux) => any,\n): TFaux => {\n return new Proxy(noop, {\n get(_obj, name) {\n if (name === 'then') {\n // special case for if the proxy is accidentally treated\n // like a PromiseLike (like in `Promise.resolve(proxy)`)\n return undefined;\n }\n return callback(name as any);\n },\n }) as TFaux;\n};\n","import type { TRPCError } from '../error/TRPCError';\nimport type { TRPC_ERROR_CODES_BY_KEY, TRPCResponse } from '../rpc';\nimport { TRPC_ERROR_CODES_BY_NUMBER } from '../rpc';\nimport type { InvertKeyValue, ValueOf } from '../types';\nimport { isObject } from '../utils';\n\nexport const JSONRPC2_TO_HTTP_CODE: Record<\n keyof typeof TRPC_ERROR_CODES_BY_KEY,\n number\n> = {\n PARSE_ERROR: 400,\n BAD_REQUEST: 400,\n UNAUTHORIZED: 401,\n PAYMENT_REQUIRED: 402,\n FORBIDDEN: 403,\n NOT_FOUND: 404,\n METHOD_NOT_SUPPORTED: 405,\n TIMEOUT: 408,\n CONFLICT: 409,\n PRECONDITION_FAILED: 412,\n PAYLOAD_TOO_LARGE: 413,\n UNSUPPORTED_MEDIA_TYPE: 415,\n UNPROCESSABLE_CONTENT: 422,\n TOO_MANY_REQUESTS: 429,\n CLIENT_CLOSED_REQUEST: 499,\n INTERNAL_SERVER_ERROR: 500,\n NOT_IMPLEMENTED: 501,\n BAD_GATEWAY: 502,\n SERVICE_UNAVAILABLE: 503,\n GATEWAY_TIMEOUT: 504,\n};\n\nexport const HTTP_CODE_TO_JSONRPC2: InvertKeyValue<\n typeof JSONRPC2_TO_HTTP_CODE\n> = {\n 400: 'BAD_REQUEST',\n 401: 'UNAUTHORIZED',\n 402: 'PAYMENT_REQUIRED',\n 403: 'FORBIDDEN',\n 404: 'NOT_FOUND',\n 405: 'METHOD_NOT_SUPPORTED',\n 408: 'TIMEOUT',\n 409: 'CONFLICT',\n 412: 'PRECONDITION_FAILED',\n 413: 'PAYLOAD_TOO_LARGE',\n 415: 'UNSUPPORTED_MEDIA_TYPE',\n 422: 'UNPROCESSABLE_CONTENT',\n 429: 'TOO_MANY_REQUESTS',\n 499: 'CLIENT_CLOSED_REQUEST',\n 500: 'INTERNAL_SERVER_ERROR',\n 501: 'NOT_IMPLEMENTED',\n 502: 'BAD_GATEWAY',\n 503: 'SERVICE_UNAVAILABLE',\n 504: 'GATEWAY_TIMEOUT',\n} as const;\n\nexport function getStatusCodeFromKey(\n code: keyof typeof TRPC_ERROR_CODES_BY_KEY,\n) {\n return JSONRPC2_TO_HTTP_CODE[code] ?? 500;\n}\n\nexport function getStatusKeyFromCode(\n code: keyof typeof HTTP_CODE_TO_JSONRPC2,\n): ValueOf<typeof HTTP_CODE_TO_JSONRPC2> {\n return HTTP_CODE_TO_JSONRPC2[code] ?? 'INTERNAL_SERVER_ERROR';\n}\n\nexport function getHTTPStatusCode(json: TRPCResponse | TRPCResponse[]) {\n const arr = Array.isArray(json) ? json : [json];\n const httpStatuses = new Set<number>(\n arr.map((res) => {\n if ('error' in res && isObject(res.error.data)) {\n if (typeof res.error.data?.['httpStatus'] === 'number') {\n return res.error.data['httpStatus'];\n }\n const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];\n return getStatusCodeFromKey(code);\n }\n return 200;\n }),\n );\n\n if (httpStatuses.size !== 1) {\n return 207;\n }\n\n const httpStatus = httpStatuses.values().next().value;\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return httpStatus!;\n}\n\nexport function getHTTPStatusCodeFromError(error: TRPCError) {\n return getStatusCodeFromKey(error.code);\n}\n","function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return module.exports = _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n return typeof o;\n } : function (o) {\n return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n }, module.exports.__esModule = true, module.exports[\"default\"] = module.exports, _typeof(o);\n}\nmodule.exports = _typeof, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var _typeof = require(\"./typeof.js\")[\"default\"];\nfunction toPrimitive(t, r) {\n if (\"object\" != _typeof(t) || !t) return t;\n var e = t[Symbol.toPrimitive];\n if (void 0 !== e) {\n var i = e.call(t, r || \"default\");\n if (\"object\" != _typeof(i)) return i;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (\"string\" === r ? String : Number)(t);\n}\nmodule.exports = toPrimitive, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var _typeof = require(\"./typeof.js\")[\"default\"];\nvar toPrimitive = require(\"./toPrimitive.js\");\nfunction toPropertyKey(t) {\n var i = toPrimitive(t, \"string\");\n return \"symbol\" == _typeof(i) ? i : i + \"\";\n}\nmodule.exports = toPropertyKey, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var toPropertyKey = require(\"./toPropertyKey.js\");\nfunction _defineProperty(e, r, t) {\n return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {\n value: t,\n enumerable: !0,\n configurable: !0,\n writable: !0\n }) : e[r] = t, e;\n}\nmodule.exports = _defineProperty, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var defineProperty = require(\"./defineProperty.js\");\nfunction ownKeys(e, r) {\n var t = Object.keys(e);\n if (Object.getOwnPropertySymbols) {\n var o = Object.getOwnPropertySymbols(e);\n r && (o = o.filter(function (r) {\n return Object.getOwnPropertyDescriptor(e, r).enumerable;\n })), t.push.apply(t, o);\n }\n return t;\n}\nfunction _objectSpread2(e) {\n for (var r = 1; r < arguments.length; r++) {\n var t = null != arguments[r] ? arguments[r] : {};\n r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {\n defineProperty(e, r, t[r]);\n }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {\n Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));\n });\n }\n return e;\n}\nmodule.exports = _objectSpread2, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","import { getHTTPStatusCodeFromError } from '../http/getHTTPStatusCode';\nimport type { ProcedureType } from '../procedure';\nimport type { AnyRootTypes, RootConfig } from '../rootConfig';\nimport { TRPC_ERROR_CODES_BY_KEY } from '../rpc';\nimport type { DefaultErrorShape } from './formatter';\nimport type { TRPCError } from './TRPCError';\n\n/**\n * @internal\n */\nexport function getErrorShape<TRoot extends AnyRootTypes>(opts: {\n config: RootConfig<TRoot>;\n error: TRPCError;\n type: ProcedureType | 'unknown';\n path: string | undefined;\n input: unknown;\n ctx: TRoot['ctx'] | undefined;\n}): TRoot['errorShape'] {\n const { path, error, config } = opts;\n const { code } = opts.error;\n const shape: DefaultErrorShape = {\n message: error.message,\n code: TRPC_ERROR_CODES_BY_KEY[code],\n data: {\n code,\n httpStatus: getHTTPStatusCodeFromError(error),\n },\n };\n if (config.isDev && typeof opts.error.stack === 'string') {\n shape.data.stack = opts.error.stack;\n }\n if (typeof path === 'string') {\n shape.data.path = path;\n }\n return config.errorFormatter({ ...opts, shape });\n}\n"],"x_google_ignoreList":[2,3,4,5,6],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,OAAO,MAAM,CAElB;AAED,MAAM,oBAAoB,CAACA,QAAgB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require_getErrorShape = require('./getErrorShape-DKiEF6Zc.cjs');
|
|
2
|
+
require('./tracked-HoF8L_mq.cjs');
|
|
3
|
+
require('./utils-BhNVZA-c.cjs');
|
|
4
|
+
const require_resolveResponse = require('./resolveResponse-CVGbakBm.cjs');
|
|
5
5
|
const require_contentTypeParsers = require('./contentTypeParsers-iAFF_pJG.cjs');
|
|
6
|
-
require('./observable-
|
|
6
|
+
require('./observable-B1Nk6r1H.cjs');
|
|
7
7
|
require('./http-DXy3XyhL.cjs');
|
|
8
8
|
|
|
9
9
|
exports.getHTTPStatusCode = require_getErrorShape.getHTTPStatusCode;
|
package/dist/http.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import "./
|
|
4
|
-
import "./
|
|
1
|
+
import { getHTTPStatusCode, getHTTPStatusCodeFromError } from "./getErrorShape-Uhlrl4Bk.mjs";
|
|
2
|
+
import "./tracked-gU3ttYjg.mjs";
|
|
3
|
+
import "./utils-DdbbrDku.mjs";
|
|
4
|
+
import { parseConnectionParamsFromString, parseConnectionParamsFromUnknown, resolveResponse } from "./resolveResponse-CzlbRpCI.mjs";
|
|
5
5
|
import { octetInputParser } from "./contentTypeParsers-SN4WL9ze.mjs";
|
|
6
|
-
import "./observable-
|
|
6
|
+
import "./observable-UMO3vUa_.mjs";
|
|
7
7
|
import "./http-CWyjOa1l.mjs";
|
|
8
8
|
|
|
9
9
|
export { getHTTPStatusCode, getHTTPStatusCodeFromError, octetInputParser, parseConnectionParamsFromString, parseConnectionParamsFromUnknown, resolveResponse };
|