@trpc/server 11.25.2 → 11.25.3-canary.13.g1341462e1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/dist/adapters/aws-lambda/index.cjs +5 -8
  2. package/dist/adapters/aws-lambda/index.d.cts +13 -5
  3. package/dist/adapters/aws-lambda/index.d.cts.map +1 -1
  4. package/dist/adapters/aws-lambda/index.d.mts +11 -5
  5. package/dist/adapters/aws-lambda/index.d.mts.map +1 -1
  6. package/dist/adapters/aws-lambda/index.mjs +5 -8
  7. package/dist/adapters/aws-lambda/index.mjs.map +1 -1
  8. package/dist/adapters/express.cjs +4 -5
  9. package/dist/adapters/express.d.cts +12 -4
  10. package/dist/adapters/express.d.cts.map +1 -1
  11. package/dist/adapters/express.d.mts +11 -4
  12. package/dist/adapters/express.d.mts.map +1 -1
  13. package/dist/adapters/express.mjs +4 -5
  14. package/dist/adapters/fastify/index.cjs +6 -8
  15. package/dist/adapters/fastify/index.d.cts +6 -8
  16. package/dist/adapters/fastify/index.d.cts.map +1 -1
  17. package/dist/adapters/fastify/index.d.mts +4 -8
  18. package/dist/adapters/fastify/index.d.mts.map +1 -1
  19. package/dist/adapters/fastify/index.mjs +6 -8
  20. package/dist/adapters/fastify/index.mjs.map +1 -1
  21. package/dist/adapters/fetch/index.cjs +3 -4
  22. package/dist/adapters/fetch/index.d.cts +3 -5
  23. package/dist/adapters/fetch/index.d.cts.map +1 -1
  24. package/dist/adapters/fetch/index.d.mts +1 -5
  25. package/dist/adapters/fetch/index.d.mts.map +1 -1
  26. package/dist/adapters/fetch/index.mjs +3 -4
  27. package/dist/adapters/next-app-dir.cjs +7 -11
  28. package/dist/adapters/next-app-dir.d.cts +8 -10
  29. package/dist/adapters/next-app-dir.d.cts.map +1 -1
  30. package/dist/adapters/next-app-dir.d.mts +7 -10
  31. package/dist/adapters/next-app-dir.d.mts.map +1 -1
  32. package/dist/adapters/next-app-dir.mjs +6 -10
  33. package/dist/adapters/next-app-dir.mjs.map +1 -1
  34. package/dist/adapters/next.cjs +5 -6
  35. package/dist/adapters/next.d.cts +12 -4
  36. package/dist/adapters/next.d.cts.map +1 -1
  37. package/dist/adapters/next.d.mts +11 -4
  38. package/dist/adapters/next.d.mts.map +1 -1
  39. package/dist/adapters/next.mjs +5 -6
  40. package/dist/adapters/node-http/index.cjs +1 -1
  41. package/dist/adapters/node-http/index.d.cts +103 -2
  42. package/dist/adapters/node-http/index.d.cts.map +1 -0
  43. package/dist/adapters/node-http/index.d.mts +1 -1
  44. package/dist/adapters/node-http/index.mjs +1 -2
  45. package/dist/adapters/standalone.cjs +5 -6
  46. package/dist/adapters/standalone.d.cts +13 -5
  47. package/dist/adapters/standalone.d.cts.map +1 -1
  48. package/dist/adapters/standalone.d.mts +12 -5
  49. package/dist/adapters/standalone.d.mts.map +1 -1
  50. package/dist/adapters/standalone.mjs +4 -5
  51. package/dist/adapters/standalone.mjs.map +1 -1
  52. package/dist/adapters/ws.cjs +1 -1
  53. package/dist/adapters/ws.d.cts +95 -3
  54. package/dist/adapters/ws.d.cts.map +1 -0
  55. package/dist/adapters/ws.d.mts +2 -2
  56. package/dist/adapters/ws.mjs +1 -2
  57. package/dist/{asyncGeneratorDelegate-JWx0LJUD.mjs → asyncGeneratorDelegate-BRQGtkYG.mjs} +30 -51
  58. package/dist/{asyncGeneratorDelegate-JWx0LJUD.mjs.map → asyncGeneratorDelegate-BRQGtkYG.mjs.map} +1 -1
  59. package/dist/{asyncGeneratorDelegate-CMdmcplC.cjs → asyncGeneratorDelegate-o88TWuuI.cjs} +29 -50
  60. package/dist/{codes-Be-DrYMh.cjs → codes-B96YeNnY.cjs} +2 -4
  61. package/dist/{codes-nbrm_zWY.mjs → codes-BCsCCyMj.mjs} +3 -5
  62. package/dist/{codes-nbrm_zWY.mjs.map → codes-BCsCCyMj.mjs.map} +1 -1
  63. package/dist/{contentTypeParsers-D1EBkFFY.mjs → contentTypeParsers-g-hK2Sqe.mjs} +2 -3
  64. package/dist/{contentTypeParsers-D1EBkFFY.mjs.map → contentTypeParsers-g-hK2Sqe.mjs.map} +1 -1
  65. package/dist/{contentTypeParsers-BTdoZrqN.cjs → contentTypeParsers-st4U3xYo.cjs} +1 -2
  66. package/dist/{getErrorShape-BAuHhNuh.cjs → getErrorShape-B1AlrJBV.cjs} +15 -24
  67. package/dist/{getErrorShape-B5jPKHJ3.mjs → getErrorShape-CVrl8_-w.mjs} +16 -25
  68. package/dist/{getErrorShape-B5jPKHJ3.mjs.map → getErrorShape-CVrl8_-w.mjs.map} +1 -1
  69. package/dist/http-11_NyRWk.d.cts +1 -0
  70. package/dist/http.cjs +3 -3
  71. package/dist/http.d.cts +2 -1
  72. package/dist/http.d.mts +1 -1
  73. package/dist/http.mjs +3 -3
  74. package/dist/{index-CFQnkrGZ.d.cts → index-BdKWn-Kv.d.cts} +1 -9
  75. package/dist/index-BdKWn-Kv.d.cts.map +1 -0
  76. package/dist/{index-CFQnkrGZ.d.mts → index-BdKWn-Kv.d.mts} +1 -9
  77. package/dist/index-BdKWn-Kv.d.mts.map +1 -0
  78. package/dist/{index-DVmu6VtT.d.mts → index-C7UHVQQf.d.mts} +2 -8
  79. package/dist/index-C7UHVQQf.d.mts.map +1 -0
  80. package/dist/index-DVXG_v0W.d.cts +9 -0
  81. package/dist/index-DVXG_v0W.d.cts.map +1 -0
  82. package/dist/index.cjs +3 -3
  83. package/dist/index.d.cts +3 -11
  84. package/dist/index.d.mts +1 -3
  85. package/dist/index.d.mts.map +1 -1
  86. package/dist/index.mjs +3 -3
  87. package/dist/{initTRPC-DPoVGUwX.mjs → initTRPC-BRhOzCfA.mjs} +15 -22
  88. package/dist/{initTRPC-DPoVGUwX.mjs.map → initTRPC-BRhOzCfA.mjs.map} +1 -1
  89. package/dist/{initTRPC-yeYwDikA.cjs → initTRPC-RIE9F856.cjs} +14 -21
  90. package/dist/{node-http-CyL_jN-0.mjs → node-http-5y0OmcF3.mjs} +8 -11
  91. package/dist/{node-http-CyL_jN-0.mjs.map → node-http-5y0OmcF3.mjs.map} +1 -1
  92. package/dist/{node-http-BnGON5Za.cjs → node-http-962IXGVP.cjs} +7 -10
  93. package/dist/observable/index.cjs +2 -2
  94. package/dist/observable/index.d.cts +1 -1
  95. package/dist/observable/index.d.mts +1 -1
  96. package/dist/observable/index.mjs +2 -2
  97. package/dist/{observable-Cmd1MFy3.mjs → observable-BjUZYMQq.mjs} +4 -6
  98. package/dist/{observable-Cmd1MFy3.mjs.map → observable-BjUZYMQq.mjs.map} +1 -1
  99. package/dist/{observable-kpFFzvou.mjs → observable-CodTG6Sf.mjs} +2 -3
  100. package/dist/{observable-kpFFzvou.mjs.map → observable-CodTG6Sf.mjs.map} +1 -1
  101. package/dist/{observable-1zKJIeLl.cjs → observable-DWjyAi42.cjs} +1 -2
  102. package/dist/{observable-CtU0hoef.cjs → observable-a_nbCVWw.cjs} +3 -5
  103. package/dist/{parseTRPCMessage-BsPr5reh.cjs → parseTRPCMessage-BHVPK_9B.cjs} +3 -5
  104. package/dist/{parseTRPCMessage-BO1-cCsX.mjs → parseTRPCMessage-_j-ul9Ni.mjs} +4 -6
  105. package/dist/{parseTRPCMessage-BO1-cCsX.mjs.map → parseTRPCMessage-_j-ul9Ni.mjs.map} +1 -1
  106. package/dist/{resolveResponse-2MBY36PP.mjs → resolveResponse-CWLbNRmT.mjs} +22 -39
  107. package/dist/{resolveResponse-2MBY36PP.mjs.map → resolveResponse-CWLbNRmT.mjs.map} +1 -1
  108. package/dist/{resolveResponse-CiTYuZCi.cjs → resolveResponse-FM4r4UGZ.cjs} +21 -38
  109. package/dist/{rolldown-runtime-CFW-PwTP.cjs → rolldown-runtime-Ct0tUeOX.cjs} +1 -2
  110. package/dist/rpc.cjs +2 -2
  111. package/dist/rpc.d.cts +1 -1
  112. package/dist/rpc.d.mts +1 -1
  113. package/dist/rpc.mjs +2 -2
  114. package/dist/shared.cjs +1 -1
  115. package/dist/shared.d.cts +2 -1
  116. package/dist/shared.d.mts +1 -1
  117. package/dist/shared.mjs +1 -2
  118. package/dist/{unstable-core-do-not-import-Db2TnFh8.d.cts → unstable-core-do-not-import-C8Gy-fzS.d.cts} +2 -84
  119. package/dist/unstable-core-do-not-import-C8Gy-fzS.d.cts.map +1 -0
  120. package/dist/{unstable-core-do-not-import-CzDUc5m2.d.mts → unstable-core-do-not-import-d-SHdPM9.d.mts} +2 -84
  121. package/dist/unstable-core-do-not-import-d-SHdPM9.d.mts.map +1 -0
  122. package/dist/unstable-core-do-not-import.cjs +8 -9
  123. package/dist/unstable-core-do-not-import.d.cts +11 -1
  124. package/dist/unstable-core-do-not-import.d.mts +11 -1
  125. package/dist/unstable-core-do-not-import.mjs +8 -9
  126. package/dist/{ws-Bl1WQEXo.mjs → ws-B4qoo-Ep.mjs} +10 -12
  127. package/dist/{ws-Bl1WQEXo.mjs.map → ws-B4qoo-Ep.mjs.map} +1 -1
  128. package/dist/{ws-BRFs3IJR.cjs → ws-D3hgtSpa.cjs} +9 -11
  129. package/dist/{ws-D-DF_k_T.d.cts → ws-DkO_xnzu.d.mts} +3 -5
  130. package/dist/ws-DkO_xnzu.d.mts.map +1 -0
  131. package/package.json +26 -26
  132. package/skills/adapter-aws-lambda/SKILL.md +1 -1
  133. package/skills/adapter-express/SKILL.md +1 -1
  134. package/skills/adapter-fastify/SKILL.md +1 -1
  135. package/skills/adapter-fetch/SKILL.md +1 -1
  136. package/skills/adapter-standalone/SKILL.md +1 -1
  137. package/skills/auth/SKILL.md +1 -1
  138. package/skills/caching/SKILL.md +1 -1
  139. package/skills/error-handling/SKILL.md +1 -1
  140. package/skills/middlewares/SKILL.md +1 -1
  141. package/skills/non-json-content-types/SKILL.md +1 -1
  142. package/skills/server-setup/SKILL.md +1 -1
  143. package/skills/server-side-calls/SKILL.md +1 -1
  144. package/skills/service-oriented-architecture/SKILL.md +1 -1
  145. package/skills/subscriptions/SKILL.md +1 -1
  146. package/skills/trpc-router/SKILL.md +1 -1
  147. package/skills/validators/SKILL.md +5 -3
  148. package/src/adapters/aws-lambda/index.ts +2 -0
  149. package/src/adapters/fastify/fastifyRequestHandler.ts +1 -1
  150. package/src/adapters/next-app-dir/redirect.ts +7 -1
  151. package/src/adapters/standalone.ts +1 -1
  152. package/dist/index-CFQnkrGZ.d.cts.map +0 -1
  153. package/dist/index-CFQnkrGZ.d.mts.map +0 -1
  154. package/dist/index-DVmu6VtT.d.mts.map +0 -1
  155. package/dist/index-Dn1ucZS5.d.cts +0 -107
  156. package/dist/index-Dn1ucZS5.d.cts.map +0 -1
  157. package/dist/index.d.cts.map +0 -1
  158. package/dist/unstable-core-do-not-import-CzDUc5m2.d.mts.map +0 -1
  159. package/dist/unstable-core-do-not-import-Db2TnFh8.d.cts.map +0 -1
  160. package/dist/ws-D-DF_k_T.d.cts.map +0 -1
  161. package/dist/ws-lJRDMspc.d.mts +0 -95
  162. package/dist/ws-lJRDMspc.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"asyncGeneratorDelegate-JWx0LJUD.mjs","names":[],"sources":["../src/unstable-core-do-not-import/error/TRPCError.ts","../src/unstable-core-do-not-import/transformer.ts","../src/unstable-core-do-not-import/router.ts","../src/unstable-core-do-not-import/http/pathSeparator.ts","../src/unstable-core-do-not-import/stream/tracked.ts"],"sourcesContent":["import type { TRPC_ERROR_CODE_KEY } from '../rpc/codes';\nimport { isObject } from '../utils';\n\nclass UnknownCauseError extends Error {\n [key: string]: unknown;\n\n constructor(cause: object) {\n super(getMessage(cause));\n Object.assign(this, cause);\n\n if (isErrorLike(cause)) {\n if (typeof cause.name === 'string') this.name = cause.name;\n if (typeof cause.stack === 'string') this.stack = cause.stack;\n }\n }\n}\n\nfunction getMessage(cause: object) {\n if ('message' in cause) return String(cause.message);\n\n return undefined;\n}\n\n/**\n * Errors from another realm (e.g. `node:vm`, iframes) fail `instanceof Error`\n * but still carry the `[object Error]` brand.\n */\nfunction isErrorLike(value: unknown): value is Error {\n return (\n value instanceof Error ||\n Object.prototype.toString.call(value) === '[object Error]'\n );\n}\n\nexport function getCauseFromUnknown(cause: unknown): Error | undefined {\n if (cause instanceof Error) {\n return cause;\n }\n\n const type = typeof cause;\n if (type === 'undefined' || type === 'function' || cause === null) {\n return undefined;\n }\n\n // Primitive types just get wrapped in an error\n if (type !== 'object') {\n // oxlint-disable-next-line typescript/no-base-to-string\n return new Error(String(cause));\n }\n\n // If it's an object, we'll create a synthetic error\n if (isObject(cause)) {\n return new UnknownCauseError(cause);\n }\n\n return undefined;\n}\n\n/**\n * Turns anything thrown into a `TRPCError`. A `TRPCError` is returned as\n * is; anything else becomes an `INTERNAL_SERVER_ERROR` with it as the\n * cause.\n */\nexport function getTRPCErrorFromUnknown(cause: unknown): TRPCError {\n if (cause instanceof TRPCError) {\n return cause;\n }\n if (cause instanceof Error && cause.name === 'TRPCError') {\n // https://github.com/trpc/trpc/pull/4848\n return cause as TRPCError;\n }\n\n const trpcError = new TRPCError({\n code: 'INTERNAL_SERVER_ERROR',\n cause,\n });\n\n // Inherit stack from error\n if (isErrorLike(cause) && cause.stack) {\n trpcError.stack = cause.stack;\n }\n\n return trpcError;\n}\n\n/**\n * An error with a tRPC error code, which sets the HTTP status and the code\n * the client sees. Throw it from resolvers and middlewares.\n * @example\n * ```ts\n * throw new TRPCError({ code: 'NOT_FOUND', message: 'No such post' });\n * ```\n * @see https://trpc.io/docs/server/error-handling#throwing-errors\n */\nexport class TRPCError extends Error {\n // oxlint-disable-next-line typescript/ban-ts-comment\n // @ts-ignore override doesn't work in all environments due to \"This member cannot have an 'override' modifier because it is not declared in the base class 'Error'\"\n /** The error this one wraps, if any. */\n public override readonly cause?: Error;\n /** The tRPC error code, such as `'NOT_FOUND'`. */\n public readonly code;\n\n constructor(opts: {\n /** Defaults to the cause's message, or else the code. */\n message?: string;\n /** @see https://trpc.io/docs/server/error-handling#error-codes */\n code: TRPC_ERROR_CODE_KEY;\n /** The original error. Anything that isn't an `Error` is wrapped in one. */\n cause?: unknown;\n }) {\n const cause = getCauseFromUnknown(opts.cause);\n const message = opts.message ?? cause?.message ?? opts.code;\n\n // oxlint-disable-next-line typescript/ban-ts-comment\n // @ts-ignore https://github.com/tc39/proposal-error-cause\n super(message, { cause });\n\n this.code = opts.code;\n this.name = 'TRPCError';\n this.cause ??= cause;\n }\n}\n","import type { AnyRootTypes, RootConfig } from './rootConfig';\nimport type { AnyRouter, inferRouterError } from './router';\nimport type {\n TRPCResponse,\n TRPCResponseMessage,\n TRPCResultMessage,\n} from './rpc';\nimport { isObject } from './utils';\n\n/**\n * A transformer that serializes and deserializes data the same way in\n * both directions, such as `superjson`.\n * @see https://trpc.io/docs/server/data-transformers#datatransformer-interface\n * @public\n */\nexport interface DataTransformer {\n serialize(object: any): any;\n deserialize(object: any): any;\n}\n\ninterface InputDataTransformer extends DataTransformer {\n /**\n * This function runs **on the client** before sending the data to the server.\n */\n serialize(object: any): any;\n /**\n * This function runs **on the server** to transform the data before it is passed to the resolver\n */\n deserialize(object: any): any;\n}\n\ninterface OutputDataTransformer extends DataTransformer {\n /**\n * This function runs **on the server** before sending the data to the client.\n */\n serialize(object: any): any;\n /**\n * This function runs **only on the client** to transform the data sent from the server.\n */\n deserialize(object: any): any;\n}\n\n/**\n * A transformer with one serializer for inputs and another for outputs.\n * @see https://trpc.io/docs/server/data-transformers#different-transformers-for-upload-and-download\n * @public\n */\nexport interface CombinedDataTransformer {\n /**\n * Specify how the data sent from the client to the server should be transformed.\n */\n input: InputDataTransformer;\n /**\n * Specify how the data sent from the server to the client should be transformed.\n */\n output: OutputDataTransformer;\n}\n\n/**\n * The half of a combined transformer the client uses: serializing inputs\n * and deserializing outputs.\n * @public\n */\nexport type CombinedDataTransformerClient = {\n input: Pick<CombinedDataTransformer['input'], 'serialize'>;\n output: Pick<CombinedDataTransformer['output'], 'deserialize'>;\n};\n\n/**\n * A transformer: one for both directions, or separate ones for inputs and\n * outputs.\n * @see https://trpc.io/docs/server/data-transformers\n * @public\n */\nexport type DataTransformerOptions = CombinedDataTransformer | DataTransformer;\n\n/**\n * @internal\n */\nexport function getDataTransformer(\n transformer: DataTransformerOptions,\n): CombinedDataTransformer {\n if ('input' in transformer) {\n return transformer;\n }\n return { input: transformer, output: transformer };\n}\n\n/**\n * @internal\n */\nexport const defaultTransformer: CombinedDataTransformer = {\n input: { serialize: (obj) => obj, deserialize: (obj) => obj },\n output: { serialize: (obj) => obj, deserialize: (obj) => obj },\n};\n\nfunction transformTRPCResponseItem<\n TResponseItem extends TRPCResponse | TRPCResponseMessage,\n>(config: RootConfig<AnyRootTypes>, item: TResponseItem): TResponseItem {\n if ('error' in item) {\n return {\n ...item,\n error: config.transformer.output.serialize(item.error),\n };\n }\n\n if ('data' in item.result) {\n return {\n ...item,\n result: {\n ...item.result,\n data: config.transformer.output.serialize(item.result.data),\n },\n };\n }\n\n return item;\n}\n\n/**\n * Serializes a response, or a list of them, with the router's output\n * transformer. Meant for custom adapters.\n **/\nexport function transformTRPCResponse<\n TResponse extends\n | TRPCResponse\n | TRPCResponse[]\n | TRPCResponseMessage\n | TRPCResponseMessage[],\n>(config: RootConfig<AnyRootTypes>, itemOrItems: TResponse) {\n return Array.isArray(itemOrItems)\n ? itemOrItems.map((item) => transformTRPCResponseItem(config, item))\n : transformTRPCResponseItem(config, itemOrItems);\n}\n\n// FIXME:\n// - the generics here are probably unnecessary\n// - the RPC-spec could probably be simplified to combine HTTP + WS\n/** @internal */\nfunction transformResultInner<TRouter extends AnyRouter, TOutput>(\n response:\n | TRPCResponse<TOutput, inferRouterError<TRouter>>\n | TRPCResponseMessage<TOutput, inferRouterError<TRouter>>,\n transformer: DataTransformer,\n) {\n if ('error' in response) {\n const error = transformer.deserialize(\n response.error,\n ) as inferRouterError<TRouter>;\n return {\n ok: false,\n error: {\n ...response,\n error,\n },\n } as const;\n }\n\n const result = {\n ...response.result,\n ...((!response.result.type || response.result.type === 'data') && {\n type: 'data',\n data: transformer.deserialize(response.result.data),\n }),\n } as TRPCResultMessage<TOutput>['result'];\n return { ok: true, result } as const;\n}\n\nclass TransformResultError extends Error {\n constructor() {\n super('Unable to transform response from server');\n }\n}\n\n/**\n * Transforms and validates that the result is a valid TRPCResponse\n * @internal\n */\nexport function transformResult<TRouter extends AnyRouter, TOutput>(\n response:\n | TRPCResponse<TOutput, inferRouterError<TRouter>>\n | TRPCResponseMessage<TOutput, inferRouterError<TRouter>>,\n transformer: DataTransformer,\n): ReturnType<typeof transformResultInner> {\n let result: ReturnType<typeof transformResultInner>;\n try {\n // Use the data transformers on the JSON-response\n result = transformResultInner(response, transformer);\n } catch {\n throw new TransformResultError();\n }\n\n // check that output of the transformers is a valid TRPCResponse\n if (\n !result.ok &&\n (!isObject(result.error.error) ||\n typeof result.error.error['code'] !== 'number')\n ) {\n throw new TransformResultError();\n }\n if (result.ok && !isObject(result.result)) {\n throw new TransformResultError();\n }\n return result;\n}\n","import type { Observable } from '../observable';\nimport { createRecursiveProxy } from './createProxy';\nimport { defaultFormatter } from './error/formatter';\nimport { getTRPCErrorFromUnknown, TRPCError } from './error/TRPCError';\nimport type { PathSeparator } from './http/pathSeparator';\nimport type {\n AnyProcedure,\n ErrorHandlerOptions,\n inferProcedureInput,\n inferProcedureOutput,\n LegacyObservableSubscriptionProcedure,\n} from './procedure';\nimport type { ProcedureCallOptions } from './procedureBuilder';\nimport type { AnyRootTypes, RootConfig } from './rootConfig';\nimport { defaultTransformer } from './transformer';\nimport type { MaybePromise, ValueOf } from './types';\nimport {\n emptyObject,\n isFunction,\n isObject,\n mergeWithoutOverrides,\n} from './utils';\n\n/**\n * The procedures and sub-routers of a router, by name.\n */\nexport interface RouterRecord {\n [key: string]: AnyProcedure | RouterRecord;\n}\n\ntype DecorateProcedure<TProcedure extends AnyProcedure> = (\n input: inferProcedureInput<TProcedure>,\n) => Promise<\n TProcedure['_def']['type'] extends 'subscription'\n ? TProcedure extends LegacyObservableSubscriptionProcedure<any>\n ? Observable<inferProcedureOutput<TProcedure>, TRPCError>\n : inferProcedureOutput<TProcedure>\n : inferProcedureOutput<TProcedure>\n>;\n\n/**\n * A router's record with every procedure turned into a function, as a\n * caller has it.\n * @internal\n */\nexport type DecorateRouterRecord<TRecord extends RouterRecord> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyProcedure\n ? DecorateProcedure<$Value>\n : $Value extends RouterRecord\n ? DecorateRouterRecord<$Value>\n : never\n : never;\n};\n\n/**\n * Called when a procedure called through a caller throws.\n * @internal\n */\nexport type RouterCallerErrorHandler<TContext> = (\n opts: ErrorHandlerOptions<TContext>,\n) => void;\n\n/**\n * Creates a caller from a context, or from a function that returns one.\n * A function is called on each procedure call, so cache it (for example\n * with `React.cache`).\n * @internal\n */\nexport type RouterCaller<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = (\n ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>),\n options?: {\n /** Called when a procedure throws, before the error is rethrown. */\n onError?: RouterCallerErrorHandler<TRoot['ctx']>;\n /**\n * Passed to middleware and resolvers as `signal`. It doesn't stop a\n * call by itself; the resolver has to check it.\n */\n signal?: AbortSignal;\n },\n) => DecorateRouterRecord<TRecord>;\n\n/**\n * @internal\n */\nconst lazyMarker = 'lazyMarker' as 'lazyMarker' & {\n __brand: 'lazyMarker';\n};\n/** A router that `lazy()` loads on its first call. */\nexport type Lazy<TAny> = (() => Promise<TAny>) & { [lazyMarker]: true };\n\ntype LazyLoader<TAny> = {\n load: () => Promise<void>;\n ref: Lazy<TAny>;\n path: readonly string[];\n key: string;\n};\n\nfunction once<T>(fn: () => T): () => T {\n const uncalled = Symbol();\n let result: T | typeof uncalled = uncalled;\n return (): T => {\n if (result === uncalled) {\n result = fn();\n }\n return result;\n };\n}\n\n/**\n * Loads a router on its first call instead of at startup, which can make\n * cold starts faster. Pass a function that imports the router, or a module\n * whose only export is the router.\n * @example\n * ```ts\n * const appRouter = router({\n * slow: lazy(() => import('./slow.js').then((m) => m.slowRouter)),\n * });\n * ```\n * @see https://trpc.io/docs/server/merging-routers#lazy-load\n */\nexport function lazy<TRouter extends AnyRouter>(\n importRouter: () => Promise<\n | TRouter\n | {\n [key: string]: TRouter;\n }\n >,\n): Lazy<NoInfer<TRouter>> {\n async function resolve(): Promise<TRouter> {\n const mod = await importRouter();\n\n // if the module is a router, return it\n if (isRouter(mod)) {\n return mod;\n }\n\n const routers = Object.values(mod);\n\n if (routers.length !== 1 || !isRouter(routers[0])) {\n throw new Error(\n \"Invalid router module - either define exactly 1 export or return the router directly.\\nExample: `lazy(() => import('./slow.js').then((m) => m.slowRouter))`\",\n );\n }\n\n return routers[0];\n }\n\n (resolve as Lazy<NoInfer<TRouter>>)[lazyMarker] = true as const;\n\n return resolve as Lazy<NoInfer<TRouter>>;\n}\n\nfunction isLazy<TAny>(input: unknown): input is Lazy<TAny> {\n return typeof input === 'function' && lazyMarker in input;\n}\n\n/**\n * A router's definition: its config and procedures.\n * @internal\n */\nexport interface RouterDef<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> {\n _config: RootConfig<TRoot>;\n router: true;\n procedure?: never;\n procedures: TRecord;\n record: TRecord;\n lazy: Record<string, LazyLoader<AnyRouter>>;\n}\n\n/**\n * A router: procedures and sub-routers under one root config.\n * @see https://trpc.io/docs/server/routers\n */\nexport interface Router<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> {\n _def: RouterDef<TRoot, TRecord>;\n /**\n * Creates a caller, which calls the router's procedures directly on the\n * server, from a context.\n * @see https://trpc.io/docs/server/server-side-calls#routercreatecaller\n */\n createCaller: RouterCaller<TRoot, TRecord>;\n}\n\n/**\n * A router as `t.router()` returns it, with its procedures and sub-routers\n * as properties.\n */\nexport type BuiltRouter<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = Router<TRoot, TRecord> & TRecord;\n\n/**\n * The type of `t.router()`.\n * @see https://trpc.io/docs/server/routers\n */\nexport interface RouterBuilder<TRoot extends AnyRootTypes> {\n <TIn extends CreateRouterOptions>(\n _: TIn,\n ): BuiltRouter<TRoot, DecorateCreateRouterOptions<TIn>>;\n}\n\n/** Any router, for use in generic constraints. */\nexport type AnyRouter = Router<any, any>;\n\n/** A router's root types: its context, metadata, error shape and transformer. */\nexport type inferRouterRootTypes<TRouter extends AnyRouter> =\n TRouter['_def']['_config']['$types'];\n\n/** The type of a router's context. */\nexport type inferRouterContext<TRouter extends AnyRouter> =\n inferRouterRootTypes<TRouter>['ctx'];\n/**\n * The shape of a router's errors, as its error formatter returns them.\n * @see https://trpc.io/docs/server/error-formatting\n */\nexport type inferRouterError<TRouter extends AnyRouter> =\n inferRouterRootTypes<TRouter>['errorShape'];\n/**\n * The type of a router's metadata.\n * @see https://trpc.io/docs/server/metadata\n */\nexport type inferRouterMeta<TRouter extends AnyRouter> =\n inferRouterRootTypes<TRouter>['meta'];\n\nfunction isRouter(value: unknown): value is AnyRouter {\n return (\n isObject(value) && isObject(value['_def']) && 'router' in value['_def']\n );\n}\n\nconst emptyRouter = {\n _ctx: null as any,\n _errorShape: null as any,\n _meta: null as any,\n queries: {},\n mutations: {},\n subscriptions: {},\n errorFormatter: defaultFormatter,\n transformer: defaultTransformer,\n};\n\n/**\n * Reserved words that can't be used as router or procedure names\n */\nconst reservedWords = [\n /**\n * Then is a reserved word because otherwise we can't return a promise that returns a Proxy\n * since JS will think that `.then` is something that exists\n */\n 'then',\n /**\n * `fn.call()` and `fn.apply()` are reserved words because otherwise we can't call a function using `.call` or `.apply`\n */\n 'call',\n 'apply',\n];\n\n/**\n * What `t.router()` takes: procedures, routers, lazy routers and nested\n * objects of them, by name.\n * @internal\n */\nexport type CreateRouterOptions = {\n [key: string]:\n | AnyProcedure\n | AnyRouter\n | CreateRouterOptions\n | Lazy<AnyRouter>;\n};\n\n/**\n * The record of the router `t.router()` builds from its options.\n * @internal\n */\nexport type DecorateCreateRouterOptions<\n TRouterOptions extends CreateRouterOptions,\n> = {\n [K in keyof TRouterOptions]: TRouterOptions[K] extends infer $Value\n ? $Value extends AnyProcedure\n ? $Value\n : $Value extends Router<any, infer TRecord>\n ? TRecord\n : $Value extends Lazy<Router<any, infer TRecord>>\n ? TRecord\n : $Value extends CreateRouterOptions\n ? DecorateCreateRouterOptions<$Value>\n : never\n : never;\n};\n\nfunction getRouterInput(router: AnyRouter) {\n const input = Object.assign(\n emptyObject<CreateRouterOptions>(),\n router._def.record,\n );\n\n for (const loader of Object.values(router._def.lazy)) {\n let record = input;\n for (const key of loader.path) {\n record = record[key] = Object.assign(\n emptyObject<CreateRouterOptions>(),\n record[key],\n );\n }\n record[loader.key] = loader.ref;\n }\n\n return input;\n}\n\n/**\n * @internal\n */\nexport function createRouterFactory<TRoot extends AnyRootTypes>(\n config: RootConfig<TRoot>,\n) {\n function createRouterInner<TInput extends CreateRouterOptions>(\n input: TInput,\n ): BuiltRouter<TRoot, DecorateCreateRouterOptions<TInput>> {\n const reservedWordsUsed = new Set(\n Object.keys(input).filter((v) => reservedWords.includes(v)),\n );\n if (reservedWordsUsed.size > 0) {\n throw new Error(\n 'Reserved words used in `router({})` call: ' +\n Array.from(reservedWordsUsed).join(', '),\n );\n }\n\n const procedures: Record<string, AnyProcedure> = emptyObject();\n const lazy: Record<string, LazyLoader<AnyRouter>> = emptyObject();\n\n function createLazyLoader(opts: {\n ref: Lazy<AnyRouter>;\n path: readonly string[];\n key: string;\n aggregate: RouterRecord;\n }): LazyLoader<AnyRouter> {\n return {\n ref: opts.ref,\n path: opts.path,\n key: opts.key,\n load: once(async () => {\n const router = await opts.ref();\n const lazyPath = [...opts.path, opts.key];\n const lazyKey = lazyPath.join('.');\n\n opts.aggregate[opts.key] = step(getRouterInput(router), lazyPath);\n\n delete lazy[lazyKey];\n }),\n };\n }\n\n const separator = config.pathSeparator;\n\n function step(from: CreateRouterOptions, path: readonly string[] = []) {\n const aggregate: RouterRecord = emptyObject();\n for (const [key, item] of Object.entries(from ?? {})) {\n if (separator !== '.' && key.includes(separator)) {\n // The URL `a_b_c` couldn't say which `_` splits a segment\n throw new Error(\n `Key \"${[...path, key].join('.')}\" contains the pathSeparator ${JSON.stringify(separator)}, so its URL would be ambiguous. Rename it or pick another pathSeparator.`,\n );\n }\n if (isLazy(item)) {\n lazy[[...path, key].join('.')] = createLazyLoader({\n path,\n ref: item,\n key,\n aggregate,\n });\n continue;\n }\n if (isRouter(item)) {\n aggregate[key] = step(getRouterInput(item), [...path, key]);\n continue;\n }\n if (!isProcedure(item)) {\n // RouterRecord\n aggregate[key] = step(item, [...path, key]);\n continue;\n }\n\n const newPath = [...path, key].join('.');\n\n if (procedures[newPath]) {\n throw new Error(`Duplicate key: ${newPath}`);\n }\n\n procedures[newPath] = item;\n aggregate[key] = item;\n }\n\n return aggregate;\n }\n const record = step(input);\n\n const _def: AnyRouter['_def'] = {\n _config: config,\n router: true,\n procedures,\n lazy,\n ...emptyRouter,\n record,\n };\n\n const router: BuiltRouter<TRoot, {}> = {\n ...(record as {}),\n _def,\n createCaller: createCallerFactory<TRoot>()({\n _def,\n }),\n };\n return router as BuiltRouter<TRoot, DecorateCreateRouterOptions<TInput>>;\n }\n\n return createRouterInner;\n}\n\nfunction isProcedure(\n procedureOrRouter: ValueOf<CreateRouterOptions>,\n): procedureOrRouter is AnyProcedure {\n return typeof procedureOrRouter === 'function';\n}\n\n/**\n * @internal\n */\nexport async function getProcedureAtPath(\n router: Pick<Router<any, any>, '_def'>,\n path: string,\n): Promise<AnyProcedure | null> {\n const { _def } = router;\n let procedure = _def.procedures[path];\n\n while (!procedure) {\n const key = Object.keys(_def.lazy).find(\n (key) => path === key || path.startsWith(key + '.'),\n );\n // console.log(`found lazy: ${key ?? 'NOPE'} (fullPath: ${fullPath})`);\n\n if (!key) {\n return null;\n }\n // console.log('loading', key, '.......');\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const lazyRouter = _def.lazy[key]!;\n await lazyRouter.load();\n\n procedure = _def.procedures[path];\n }\n\n return procedure;\n}\n\n/**\n * Calls the procedure at `path`, throwing `NOT_FOUND` if there's none of\n * that type.\n * @internal\n */\nexport async function callProcedure(\n opts: ProcedureCallOptions<unknown> & {\n router: AnyRouter;\n allowMethodOverride?: boolean;\n },\n) {\n const { type, path } = opts;\n const proc = await getProcedureAtPath(opts.router, path);\n if (\n !proc ||\n !isProcedure(proc) ||\n (proc._def.type !== type && !opts.allowMethodOverride)\n ) {\n throw new TRPCError({\n code: 'NOT_FOUND',\n message: `No \"${type}\"-procedure on path \"${path}\"`,\n });\n }\n\n /* istanbul ignore if -- @preserve */\n if (\n proc._def.type !== type &&\n opts.allowMethodOverride &&\n proc._def.type === 'subscription'\n ) {\n throw new TRPCError({\n code: 'METHOD_NOT_SUPPORTED',\n message: `Method override is not supported for subscriptions`,\n });\n }\n\n return proc(opts);\n}\n\n/**\n * The type of `t.createCallerFactory()`: takes a router and returns its\n * `createCaller`.\n * @see https://trpc.io/docs/server/server-side-calls#create-caller\n */\nexport interface RouterCallerFactory<TRoot extends AnyRootTypes> {\n <TRecord extends RouterRecord>(\n router: Pick<Router<TRoot, TRecord>, '_def'>,\n ): RouterCaller<TRoot, TRecord>;\n}\n\nexport function createCallerFactory<\n TRoot extends AnyRootTypes,\n>(): RouterCallerFactory<TRoot> {\n return function createCallerInner<TRecord extends RouterRecord>(\n router: Pick<Router<TRoot, TRecord>, '_def'>,\n ): RouterCaller<TRoot, TRecord> {\n const { _def } = router;\n type Context = TRoot['ctx'];\n\n return function createCaller(ctxOrCallback, opts) {\n return createRecursiveProxy<ReturnType<RouterCaller<any, any>>>(\n async (innerOpts) => {\n const { path, args } = innerOpts;\n const fullPath = path.join('.');\n\n if (path.length === 1 && path[0] === '_def') {\n return _def;\n }\n\n const procedure = await getProcedureAtPath(router, fullPath);\n\n let ctx: Context | undefined = undefined;\n try {\n if (!procedure) {\n throw new TRPCError({\n code: 'NOT_FOUND',\n message: `No procedure found on path \"${path}\"`,\n });\n }\n ctx = isFunction(ctxOrCallback)\n ? await Promise.resolve(ctxOrCallback())\n : ctxOrCallback;\n\n return await procedure({\n path: fullPath,\n getRawInput: async () => args[0],\n ctx,\n type: procedure._def.type,\n signal: opts?.signal,\n batchIndex: 0,\n });\n } catch (cause) {\n opts?.onError?.({\n ctx,\n error: getTRPCErrorFromUnknown(cause),\n input: args[0],\n path: fullPath,\n type: procedure?._def.type ?? 'unknown',\n });\n throw cause;\n }\n },\n );\n };\n };\n}\n\n/**\n * The router `t.mergeRouters()` returns.\n * @internal\n */\nexport type MergeRouters<\n TRouters extends AnyRouter[],\n TRoot extends AnyRootTypes = TRouters[0]['_def']['_config']['$types'],\n TRecord extends RouterRecord = {},\n> = TRouters extends [\n infer Head extends AnyRouter,\n ...infer Tail extends AnyRouter[],\n]\n ? MergeRouters<Tail, TRoot, Head['_def']['record'] & TRecord>\n : BuiltRouter<TRoot, TRecord>;\n\nexport function mergeRouters<TRouters extends AnyRouter[]>(\n ...routerList: [...TRouters]\n): MergeRouters<TRouters> {\n const record = mergeWithoutOverrides(\n {},\n ...[...new Set(routerList)].map((r) => getRouterInput(r)),\n );\n const errorFormatter = routerList.reduce(\n (currentErrorFormatter, nextRouter) => {\n if (\n nextRouter._def._config.errorFormatter &&\n nextRouter._def._config.errorFormatter !== defaultFormatter\n ) {\n if (\n currentErrorFormatter !== defaultFormatter &&\n currentErrorFormatter !== nextRouter._def._config.errorFormatter\n ) {\n throw new Error('You seem to have several error formatters');\n }\n return nextRouter._def._config.errorFormatter;\n }\n return currentErrorFormatter;\n },\n defaultFormatter,\n );\n\n const transformer = routerList.reduce((prev, current) => {\n if (\n current._def._config.transformer &&\n current._def._config.transformer !== defaultTransformer\n ) {\n if (\n prev !== defaultTransformer &&\n prev !== current._def._config.transformer\n ) {\n throw new Error('You seem to have several transformers');\n }\n return current._def._config.transformer;\n }\n return prev;\n }, defaultTransformer);\n\n const pathSeparator = routerList.reduce<PathSeparator>((prev, current) => {\n const next = current._def._config.pathSeparator;\n if (next === '.') {\n return prev;\n }\n if (prev !== '.' && prev !== next) {\n throw new Error('You seem to have several pathSeparators');\n }\n return next;\n }, '.');\n\n const router = createRouterFactory({\n errorFormatter,\n transformer,\n pathSeparator,\n isDev: routerList.every((r) => r._def._config.isDev),\n allowOutsideOfServer: routerList.every(\n (r) => r._def._config.allowOutsideOfServer,\n ),\n isServer: routerList.every((r) => r._def._config.isServer),\n $types: routerList[0]?._def._config.$types,\n sse: routerList[0]?._def._config.sse,\n })(record);\n\n return router as MergeRouters<TRouters>;\n}\n","/**\n * The character between a procedure path's segments in HTTP URLs, such as\n * the `~` in `/trpc/post~byId`. Procedure paths stay dotted everywhere else:\n * in middlewares, errors, `onError` and query keys.\n *\n * These are the URL \"unreserved\" punctuation characters (RFC 3986), which\n * are never percent-encoded or normalised and mean nothing to routers. `/`\n * would need catch-all routes in every adapter, and `,` separates batched\n * calls.\n */\nexport type PathSeparator = '.' | '_' | '~' | '-';\n\n/**\n * Applies the `'.'` default to a user-given `pathSeparator` option. Call it\n * once, where the option is read.\n * @internal\n */\nexport function resolvePathSeparator(\n value: PathSeparator | undefined,\n): PathSeparator {\n return value ?? '.';\n}\n\n/**\n * `post.byId` → `post~byId`, for building URLs.\n * @internal\n */\nexport function procedurePathToURLPath(\n path: string,\n separator: PathSeparator,\n): string {\n if (separator === '.') {\n return path;\n }\n return path.split('.').join(separator);\n}\n\n/**\n * `post~byId` → `post.byId`, for reading URLs. Dotted paths still resolve,\n * so clients can move to the separator after the server does.\n * @internal\n */\nexport function urlPathToProcedurePath(\n path: string,\n separator: PathSeparator,\n): string {\n if (separator === '.') {\n return path;\n }\n return path.split(separator).join('.');\n}\n","const trackedSymbol = Symbol();\n\ntype TrackedId = string & {\n __brand: 'TrackedId';\n};\n/** An event wrapped by `tracked()`, with its id. */\nexport type TrackedEnvelope<TData> = [TrackedId, TData, typeof trackedSymbol];\n\n/** A tracked event as the client gets it. */\nexport interface TrackedData<TData> {\n /**\n * The event's id, which the client sends back as `lastEventId` when it\n * reconnects.\n */\n id: string;\n /**\n * The event's data.\n */\n data: TData;\n}\n/**\n * Wraps an event with an id, so a client can resume from it.\n * @deprecated Use `tracked(id, data)` instead.\n */\nexport function sse<TData>(event: { id: string; data: TData }) {\n return tracked(event.id, event.data);\n}\n\n/** Whether a value was made by `tracked()`. */\nexport function isTrackedEnvelope<TData>(\n value: unknown,\n): value is TrackedEnvelope<TData> {\n return Array.isArray(value) && value[2] === trackedSymbol;\n}\n\n/**\n * Gives a subscription event an id. When the connection drops, the client\n * reconnects with the last id it got, as `input.lastEventId`, so the\n * subscription can resume from there. The id can't be empty.\n * @example\n * ```ts\n * yield tracked(post.id, post);\n * ```\n * @see https://trpc.io/docs/server/subscriptions#tracked\n */\nexport function tracked<TData>(\n id: string,\n data: TData,\n): TrackedEnvelope<TData> {\n if (id === '') {\n // This limitation could be removed by using different SSE event names / channels for tracked event and non-tracked event\n throw new Error(\n '`id` must not be an empty string as empty string is the same as not setting the id at all',\n );\n }\n if (/[\\0\\n\\r]/.test(id)) {\n throw new Error(\n '`id` must not contain line breaks or null characters as they are not allowed in a Server-Sent Events id',\n );\n }\n return [id as TrackedId, data, trackedSymbol];\n}\n\n/** The type a client gets for an event, unwrapping `tracked()` events. */\nexport type inferTrackedOutput<TData> =\n TData extends TrackedEnvelope<infer $Data> ? TrackedData<$Data> : TData;\n"],"mappings":";;;AAGA,IAAM,oBAAN,cAAgC,MAAM;CAGpC,YAAY,OAAe;EACzB,MAAM,WAAW,KAAK,CAAC;EACvB,OAAO,OAAO,MAAM,KAAK;EAEzB,IAAI,YAAY,KAAK,GAAG;GACtB,IAAI,OAAO,MAAM,SAAS,UAAU,KAAK,OAAO,MAAM;GACtD,IAAI,OAAO,MAAM,UAAU,UAAU,KAAK,QAAQ,MAAM;EAC1D;CACF;AACF;AAEA,SAAS,WAAW,OAAe;CACjC,IAAI,aAAa,OAAO,OAAO,OAAO,MAAM,OAAO;AAGrD;;;;;AAMA,SAAS,YAAY,OAAgC;CACnD,OACE,iBAAiB,SACjB,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM;AAE9C;AAEA,SAAgB,oBAAoB,OAAmC;CACrE,IA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AW,QAAA,QAAA,iBAAA,KAAA,IAAA,KAAA,IAAA,aAAI,KAAK,QAAQ;EACpC,MAAA,gBAAK,WAAW,QAAA,QAAA,kBAAA,KAAA,IAAA,KAAA,IAAA,cAAI,KAAK,QAAQ;CACnC,CAAC,CAAC,CAAC,MAES;AACd;;;;;;;;AC/nBA,SAAgB,qBACd,OACe;CACf,OAAO,UAAA,QAAA,UAAA,KAAA,IAAA,QAAS;AAClB;;;;;AAMA,SAAgB,uBACd,MACA,WACQ;CACR,IAAI,cAAc,KAChB,OAAO;CAET,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,SAAS;AACvC;;;;;;AAOA,SAAgB,uBACd,MACA,WACQ;CACR,IAAI,cAAc,KAChB,OAAO;CAET,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,KAAK,GAAG;AACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClDA,MAAM,gBAAgB,OAAO;;;;;AAwB7B,SAAgB,IAAW,OAAoC;CAC7D,OAAO,QAAQ,MAAM,IAAI,MAAM,IAAI;AACrC;;AAGA,SAAgB,kBACd,OACiC;CACjC,OAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAO;AAC9C;;;;;;;;;;;AAYA,SAAgB,QACd,IACA,MACwB;CACxB,IAAI,OAAO,IAET,MAAM,IAAI,MACR,2FACF;CAEF,IAAI,WAAW,KAAK,EAAE,GACpB,MAAM,IAAI,MACR,yGACF;CAEF,OAAO;EAAC;EAAiB;EAAM;CAAa;AAC9C"}
1
+ {"version":3,"file":"asyncGeneratorDelegate-BRQGtkYG.mjs","names":[],"sources":["../src/unstable-core-do-not-import/error/TRPCError.ts","../src/unstable-core-do-not-import/transformer.ts","../src/unstable-core-do-not-import/router.ts","../src/unstable-core-do-not-import/http/pathSeparator.ts","../src/unstable-core-do-not-import/stream/tracked.ts"],"sourcesContent":["import type { TRPC_ERROR_CODE_KEY } from '../rpc/codes';\nimport { isObject } from '../utils';\n\nclass UnknownCauseError extends Error {\n [key: string]: unknown;\n\n constructor(cause: object) {\n super(getMessage(cause));\n Object.assign(this, cause);\n\n if (isErrorLike(cause)) {\n if (typeof cause.name === 'string') this.name = cause.name;\n if (typeof cause.stack === 'string') this.stack = cause.stack;\n }\n }\n}\n\nfunction getMessage(cause: object) {\n if ('message' in cause) return String(cause.message);\n\n return undefined;\n}\n\n/**\n * Errors from another realm (e.g. `node:vm`, iframes) fail `instanceof Error`\n * but still carry the `[object Error]` brand.\n */\nfunction isErrorLike(value: unknown): value is Error {\n return (\n value instanceof Error ||\n Object.prototype.toString.call(value) === '[object Error]'\n );\n}\n\nexport function getCauseFromUnknown(cause: unknown): Error | undefined {\n if (cause instanceof Error) {\n return cause;\n }\n\n const type = typeof cause;\n if (type === 'undefined' || type === 'function' || cause === null) {\n return undefined;\n }\n\n // Primitive types just get wrapped in an error\n if (type !== 'object') {\n // oxlint-disable-next-line typescript/no-base-to-string\n return new Error(String(cause));\n }\n\n // If it's an object, we'll create a synthetic error\n if (isObject(cause)) {\n return new UnknownCauseError(cause);\n }\n\n return undefined;\n}\n\n/**\n * Turns anything thrown into a `TRPCError`. A `TRPCError` is returned as\n * is; anything else becomes an `INTERNAL_SERVER_ERROR` with it as the\n * cause.\n */\nexport function getTRPCErrorFromUnknown(cause: unknown): TRPCError {\n if (cause instanceof TRPCError) {\n return cause;\n }\n if (cause instanceof Error && cause.name === 'TRPCError') {\n // https://github.com/trpc/trpc/pull/4848\n return cause as TRPCError;\n }\n\n const trpcError = new TRPCError({\n code: 'INTERNAL_SERVER_ERROR',\n cause,\n });\n\n // Inherit stack from error\n if (isErrorLike(cause) && cause.stack) {\n trpcError.stack = cause.stack;\n }\n\n return trpcError;\n}\n\n/**\n * An error with a tRPC error code, which sets the HTTP status and the code\n * the client sees. Throw it from resolvers and middlewares.\n * @example\n * ```ts\n * throw new TRPCError({ code: 'NOT_FOUND', message: 'No such post' });\n * ```\n * @see https://trpc.io/docs/server/error-handling#throwing-errors\n */\nexport class TRPCError extends Error {\n // oxlint-disable-next-line typescript/ban-ts-comment\n // @ts-ignore override doesn't work in all environments due to \"This member cannot have an 'override' modifier because it is not declared in the base class 'Error'\"\n /** The error this one wraps, if any. */\n public override readonly cause?: Error;\n /** The tRPC error code, such as `'NOT_FOUND'`. */\n public readonly code;\n\n constructor(opts: {\n /** Defaults to the cause's message, or else the code. */\n message?: string;\n /** @see https://trpc.io/docs/server/error-handling#error-codes */\n code: TRPC_ERROR_CODE_KEY;\n /** The original error. Anything that isn't an `Error` is wrapped in one. */\n cause?: unknown;\n }) {\n const cause = getCauseFromUnknown(opts.cause);\n const message = opts.message ?? cause?.message ?? opts.code;\n\n // oxlint-disable-next-line typescript/ban-ts-comment\n // @ts-ignore https://github.com/tc39/proposal-error-cause\n super(message, { cause });\n\n this.code = opts.code;\n this.name = 'TRPCError';\n this.cause ??= cause;\n }\n}\n","import type { AnyRootTypes, RootConfig } from './rootConfig';\nimport type { AnyRouter, inferRouterError } from './router';\nimport type {\n TRPCResponse,\n TRPCResponseMessage,\n TRPCResultMessage,\n} from './rpc';\nimport { isObject } from './utils';\n\n/**\n * A transformer that serializes and deserializes data the same way in\n * both directions, such as `superjson`.\n * @see https://trpc.io/docs/server/data-transformers#datatransformer-interface\n * @public\n */\nexport interface DataTransformer {\n serialize(object: any): any;\n deserialize(object: any): any;\n}\n\ninterface InputDataTransformer extends DataTransformer {\n /**\n * This function runs **on the client** before sending the data to the server.\n */\n serialize(object: any): any;\n /**\n * This function runs **on the server** to transform the data before it is passed to the resolver\n */\n deserialize(object: any): any;\n}\n\ninterface OutputDataTransformer extends DataTransformer {\n /**\n * This function runs **on the server** before sending the data to the client.\n */\n serialize(object: any): any;\n /**\n * This function runs **only on the client** to transform the data sent from the server.\n */\n deserialize(object: any): any;\n}\n\n/**\n * A transformer with one serializer for inputs and another for outputs.\n * @see https://trpc.io/docs/server/data-transformers#different-transformers-for-upload-and-download\n * @public\n */\nexport interface CombinedDataTransformer {\n /**\n * Specify how the data sent from the client to the server should be transformed.\n */\n input: InputDataTransformer;\n /**\n * Specify how the data sent from the server to the client should be transformed.\n */\n output: OutputDataTransformer;\n}\n\n/**\n * The half of a combined transformer the client uses: serializing inputs\n * and deserializing outputs.\n * @public\n */\nexport type CombinedDataTransformerClient = {\n input: Pick<CombinedDataTransformer['input'], 'serialize'>;\n output: Pick<CombinedDataTransformer['output'], 'deserialize'>;\n};\n\n/**\n * A transformer: one for both directions, or separate ones for inputs and\n * outputs.\n * @see https://trpc.io/docs/server/data-transformers\n * @public\n */\nexport type DataTransformerOptions = CombinedDataTransformer | DataTransformer;\n\n/**\n * @internal\n */\nexport function getDataTransformer(\n transformer: DataTransformerOptions,\n): CombinedDataTransformer {\n if ('input' in transformer) {\n return transformer;\n }\n return { input: transformer, output: transformer };\n}\n\n/**\n * @internal\n */\nexport const defaultTransformer: CombinedDataTransformer = {\n input: { serialize: (obj) => obj, deserialize: (obj) => obj },\n output: { serialize: (obj) => obj, deserialize: (obj) => obj },\n};\n\nfunction transformTRPCResponseItem<\n TResponseItem extends TRPCResponse | TRPCResponseMessage,\n>(config: RootConfig<AnyRootTypes>, item: TResponseItem): TResponseItem {\n if ('error' in item) {\n return {\n ...item,\n error: config.transformer.output.serialize(item.error),\n };\n }\n\n if ('data' in item.result) {\n return {\n ...item,\n result: {\n ...item.result,\n data: config.transformer.output.serialize(item.result.data),\n },\n };\n }\n\n return item;\n}\n\n/**\n * Serializes a response, or a list of them, with the router's output\n * transformer. Meant for custom adapters.\n **/\nexport function transformTRPCResponse<\n TResponse extends\n | TRPCResponse\n | TRPCResponse[]\n | TRPCResponseMessage\n | TRPCResponseMessage[],\n>(config: RootConfig<AnyRootTypes>, itemOrItems: TResponse) {\n return Array.isArray(itemOrItems)\n ? itemOrItems.map((item) => transformTRPCResponseItem(config, item))\n : transformTRPCResponseItem(config, itemOrItems);\n}\n\n// FIXME:\n// - the generics here are probably unnecessary\n// - the RPC-spec could probably be simplified to combine HTTP + WS\n/** @internal */\nfunction transformResultInner<TRouter extends AnyRouter, TOutput>(\n response:\n | TRPCResponse<TOutput, inferRouterError<TRouter>>\n | TRPCResponseMessage<TOutput, inferRouterError<TRouter>>,\n transformer: DataTransformer,\n) {\n if ('error' in response) {\n const error = transformer.deserialize(\n response.error,\n ) as inferRouterError<TRouter>;\n return {\n ok: false,\n error: {\n ...response,\n error,\n },\n } as const;\n }\n\n const result = {\n ...response.result,\n ...((!response.result.type || response.result.type === 'data') && {\n type: 'data',\n data: transformer.deserialize(response.result.data),\n }),\n } as TRPCResultMessage<TOutput>['result'];\n return { ok: true, result } as const;\n}\n\nclass TransformResultError extends Error {\n constructor() {\n super('Unable to transform response from server');\n }\n}\n\n/**\n * Transforms and validates that the result is a valid TRPCResponse\n * @internal\n */\nexport function transformResult<TRouter extends AnyRouter, TOutput>(\n response:\n | TRPCResponse<TOutput, inferRouterError<TRouter>>\n | TRPCResponseMessage<TOutput, inferRouterError<TRouter>>,\n transformer: DataTransformer,\n): ReturnType<typeof transformResultInner> {\n let result: ReturnType<typeof transformResultInner>;\n try {\n // Use the data transformers on the JSON-response\n result = transformResultInner(response, transformer);\n } catch {\n throw new TransformResultError();\n }\n\n // check that output of the transformers is a valid TRPCResponse\n if (\n !result.ok &&\n (!isObject(result.error.error) ||\n typeof result.error.error['code'] !== 'number')\n ) {\n throw new TransformResultError();\n }\n if (result.ok && !isObject(result.result)) {\n throw new TransformResultError();\n }\n return result;\n}\n","import type { Observable } from '../observable';\nimport { createRecursiveProxy } from './createProxy';\nimport { defaultFormatter } from './error/formatter';\nimport { getTRPCErrorFromUnknown, TRPCError } from './error/TRPCError';\nimport type { PathSeparator } from './http/pathSeparator';\nimport type {\n AnyProcedure,\n ErrorHandlerOptions,\n inferProcedureInput,\n inferProcedureOutput,\n LegacyObservableSubscriptionProcedure,\n} from './procedure';\nimport type { ProcedureCallOptions } from './procedureBuilder';\nimport type { AnyRootTypes, RootConfig } from './rootConfig';\nimport { defaultTransformer } from './transformer';\nimport type { MaybePromise, ValueOf } from './types';\nimport {\n emptyObject,\n isFunction,\n isObject,\n mergeWithoutOverrides,\n} from './utils';\n\n/**\n * The procedures and sub-routers of a router, by name.\n */\nexport interface RouterRecord {\n [key: string]: AnyProcedure | RouterRecord;\n}\n\ntype DecorateProcedure<TProcedure extends AnyProcedure> = (\n input: inferProcedureInput<TProcedure>,\n) => Promise<\n TProcedure['_def']['type'] extends 'subscription'\n ? TProcedure extends LegacyObservableSubscriptionProcedure<any>\n ? Observable<inferProcedureOutput<TProcedure>, TRPCError>\n : inferProcedureOutput<TProcedure>\n : inferProcedureOutput<TProcedure>\n>;\n\n/**\n * A router's record with every procedure turned into a function, as a\n * caller has it.\n * @internal\n */\nexport type DecorateRouterRecord<TRecord extends RouterRecord> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyProcedure\n ? DecorateProcedure<$Value>\n : $Value extends RouterRecord\n ? DecorateRouterRecord<$Value>\n : never\n : never;\n};\n\n/**\n * Called when a procedure called through a caller throws.\n * @internal\n */\nexport type RouterCallerErrorHandler<TContext> = (\n opts: ErrorHandlerOptions<TContext>,\n) => void;\n\n/**\n * Creates a caller from a context, or from a function that returns one.\n * A function is called on each procedure call, so cache it (for example\n * with `React.cache`).\n * @internal\n */\nexport type RouterCaller<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = (\n ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>),\n options?: {\n /** Called when a procedure throws, before the error is rethrown. */\n onError?: RouterCallerErrorHandler<TRoot['ctx']>;\n /**\n * Passed to middleware and resolvers as `signal`. It doesn't stop a\n * call by itself; the resolver has to check it.\n */\n signal?: AbortSignal;\n },\n) => DecorateRouterRecord<TRecord>;\n\n/**\n * @internal\n */\nconst lazyMarker = 'lazyMarker' as 'lazyMarker' & {\n __brand: 'lazyMarker';\n};\n/** A router that `lazy()` loads on its first call. */\nexport type Lazy<TAny> = (() => Promise<TAny>) & { [lazyMarker]: true };\n\ntype LazyLoader<TAny> = {\n load: () => Promise<void>;\n ref: Lazy<TAny>;\n path: readonly string[];\n key: string;\n};\n\nfunction once<T>(fn: () => T): () => T {\n const uncalled = Symbol();\n let result: T | typeof uncalled = uncalled;\n return (): T => {\n if (result === uncalled) {\n result = fn();\n }\n return result;\n };\n}\n\n/**\n * Loads a router on its first call instead of at startup, which can make\n * cold starts faster. Pass a function that imports the router, or a module\n * whose only export is the router.\n * @example\n * ```ts\n * const appRouter = router({\n * slow: lazy(() => import('./slow.js').then((m) => m.slowRouter)),\n * });\n * ```\n * @see https://trpc.io/docs/server/merging-routers#lazy-load\n */\nexport function lazy<TRouter extends AnyRouter>(\n importRouter: () => Promise<\n | TRouter\n | {\n [key: string]: TRouter;\n }\n >,\n): Lazy<NoInfer<TRouter>> {\n async function resolve(): Promise<TRouter> {\n const mod = await importRouter();\n\n // if the module is a router, return it\n if (isRouter(mod)) {\n return mod;\n }\n\n const routers = Object.values(mod);\n\n if (routers.length !== 1 || !isRouter(routers[0])) {\n throw new Error(\n \"Invalid router module - either define exactly 1 export or return the router directly.\\nExample: `lazy(() => import('./slow.js').then((m) => m.slowRouter))`\",\n );\n }\n\n return routers[0];\n }\n\n (resolve as Lazy<NoInfer<TRouter>>)[lazyMarker] = true as const;\n\n return resolve as Lazy<NoInfer<TRouter>>;\n}\n\nfunction isLazy<TAny>(input: unknown): input is Lazy<TAny> {\n return typeof input === 'function' && lazyMarker in input;\n}\n\n/**\n * A router's definition: its config and procedures.\n * @internal\n */\nexport interface RouterDef<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> {\n _config: RootConfig<TRoot>;\n router: true;\n procedure?: never;\n procedures: TRecord;\n record: TRecord;\n lazy: Record<string, LazyLoader<AnyRouter>>;\n}\n\n/**\n * A router: procedures and sub-routers under one root config.\n * @see https://trpc.io/docs/server/routers\n */\nexport interface Router<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> {\n _def: RouterDef<TRoot, TRecord>;\n /**\n * Creates a caller, which calls the router's procedures directly on the\n * server, from a context.\n * @see https://trpc.io/docs/server/server-side-calls#routercreatecaller\n */\n createCaller: RouterCaller<TRoot, TRecord>;\n}\n\n/**\n * A router as `t.router()` returns it, with its procedures and sub-routers\n * as properties.\n */\nexport type BuiltRouter<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = Router<TRoot, TRecord> & TRecord;\n\n/**\n * The type of `t.router()`.\n * @see https://trpc.io/docs/server/routers\n */\nexport interface RouterBuilder<TRoot extends AnyRootTypes> {\n <TIn extends CreateRouterOptions>(\n _: TIn,\n ): BuiltRouter<TRoot, DecorateCreateRouterOptions<TIn>>;\n}\n\n/** Any router, for use in generic constraints. */\nexport type AnyRouter = Router<any, any>;\n\n/** A router's root types: its context, metadata, error shape and transformer. */\nexport type inferRouterRootTypes<TRouter extends AnyRouter> =\n TRouter['_def']['_config']['$types'];\n\n/** The type of a router's context. */\nexport type inferRouterContext<TRouter extends AnyRouter> =\n inferRouterRootTypes<TRouter>['ctx'];\n/**\n * The shape of a router's errors, as its error formatter returns them.\n * @see https://trpc.io/docs/server/error-formatting\n */\nexport type inferRouterError<TRouter extends AnyRouter> =\n inferRouterRootTypes<TRouter>['errorShape'];\n/**\n * The type of a router's metadata.\n * @see https://trpc.io/docs/server/metadata\n */\nexport type inferRouterMeta<TRouter extends AnyRouter> =\n inferRouterRootTypes<TRouter>['meta'];\n\nfunction isRouter(value: unknown): value is AnyRouter {\n return (\n isObject(value) && isObject(value['_def']) && 'router' in value['_def']\n );\n}\n\nconst emptyRouter = {\n _ctx: null as any,\n _errorShape: null as any,\n _meta: null as any,\n queries: {},\n mutations: {},\n subscriptions: {},\n errorFormatter: defaultFormatter,\n transformer: defaultTransformer,\n};\n\n/**\n * Reserved words that can't be used as router or procedure names\n */\nconst reservedWords = [\n /**\n * Then is a reserved word because otherwise we can't return a promise that returns a Proxy\n * since JS will think that `.then` is something that exists\n */\n 'then',\n /**\n * `fn.call()` and `fn.apply()` are reserved words because otherwise we can't call a function using `.call` or `.apply`\n */\n 'call',\n 'apply',\n];\n\n/**\n * What `t.router()` takes: procedures, routers, lazy routers and nested\n * objects of them, by name.\n * @internal\n */\nexport type CreateRouterOptions = {\n [key: string]:\n | AnyProcedure\n | AnyRouter\n | CreateRouterOptions\n | Lazy<AnyRouter>;\n};\n\n/**\n * The record of the router `t.router()` builds from its options.\n * @internal\n */\nexport type DecorateCreateRouterOptions<\n TRouterOptions extends CreateRouterOptions,\n> = {\n [K in keyof TRouterOptions]: TRouterOptions[K] extends infer $Value\n ? $Value extends AnyProcedure\n ? $Value\n : $Value extends Router<any, infer TRecord>\n ? TRecord\n : $Value extends Lazy<Router<any, infer TRecord>>\n ? TRecord\n : $Value extends CreateRouterOptions\n ? DecorateCreateRouterOptions<$Value>\n : never\n : never;\n};\n\nfunction getRouterInput(router: AnyRouter) {\n const input = Object.assign(\n emptyObject<CreateRouterOptions>(),\n router._def.record,\n );\n\n for (const loader of Object.values(router._def.lazy)) {\n let record = input;\n for (const key of loader.path) {\n record = record[key] = Object.assign(\n emptyObject<CreateRouterOptions>(),\n record[key],\n );\n }\n record[loader.key] = loader.ref;\n }\n\n return input;\n}\n\n/**\n * @internal\n */\nexport function createRouterFactory<TRoot extends AnyRootTypes>(\n config: RootConfig<TRoot>,\n) {\n function createRouterInner<TInput extends CreateRouterOptions>(\n input: TInput,\n ): BuiltRouter<TRoot, DecorateCreateRouterOptions<TInput>> {\n const reservedWordsUsed = new Set(\n Object.keys(input).filter((v) => reservedWords.includes(v)),\n );\n if (reservedWordsUsed.size > 0) {\n throw new Error(\n 'Reserved words used in `router({})` call: ' +\n Array.from(reservedWordsUsed).join(', '),\n );\n }\n\n const procedures: Record<string, AnyProcedure> = emptyObject();\n const lazy: Record<string, LazyLoader<AnyRouter>> = emptyObject();\n\n function createLazyLoader(opts: {\n ref: Lazy<AnyRouter>;\n path: readonly string[];\n key: string;\n aggregate: RouterRecord;\n }): LazyLoader<AnyRouter> {\n return {\n ref: opts.ref,\n path: opts.path,\n key: opts.key,\n load: once(async () => {\n const router = await opts.ref();\n const lazyPath = [...opts.path, opts.key];\n const lazyKey = lazyPath.join('.');\n\n opts.aggregate[opts.key] = step(getRouterInput(router), lazyPath);\n\n delete lazy[lazyKey];\n }),\n };\n }\n\n const separator = config.pathSeparator;\n\n function step(from: CreateRouterOptions, path: readonly string[] = []) {\n const aggregate: RouterRecord = emptyObject();\n for (const [key, item] of Object.entries(from ?? {})) {\n if (separator !== '.' && key.includes(separator)) {\n // The URL `a_b_c` couldn't say which `_` splits a segment\n throw new Error(\n `Key \"${[...path, key].join('.')}\" contains the pathSeparator ${JSON.stringify(separator)}, so its URL would be ambiguous. Rename it or pick another pathSeparator.`,\n );\n }\n if (isLazy(item)) {\n lazy[[...path, key].join('.')] = createLazyLoader({\n path,\n ref: item,\n key,\n aggregate,\n });\n continue;\n }\n if (isRouter(item)) {\n aggregate[key] = step(getRouterInput(item), [...path, key]);\n continue;\n }\n if (!isProcedure(item)) {\n // RouterRecord\n aggregate[key] = step(item, [...path, key]);\n continue;\n }\n\n const newPath = [...path, key].join('.');\n\n if (procedures[newPath]) {\n throw new Error(`Duplicate key: ${newPath}`);\n }\n\n procedures[newPath] = item;\n aggregate[key] = item;\n }\n\n return aggregate;\n }\n const record = step(input);\n\n const _def: AnyRouter['_def'] = {\n _config: config,\n router: true,\n procedures,\n lazy,\n ...emptyRouter,\n record,\n };\n\n const router: BuiltRouter<TRoot, {}> = {\n ...(record as {}),\n _def,\n createCaller: createCallerFactory<TRoot>()({\n _def,\n }),\n };\n return router as BuiltRouter<TRoot, DecorateCreateRouterOptions<TInput>>;\n }\n\n return createRouterInner;\n}\n\nfunction isProcedure(\n procedureOrRouter: ValueOf<CreateRouterOptions>,\n): procedureOrRouter is AnyProcedure {\n return typeof procedureOrRouter === 'function';\n}\n\n/**\n * @internal\n */\nexport async function getProcedureAtPath(\n router: Pick<Router<any, any>, '_def'>,\n path: string,\n): Promise<AnyProcedure | null> {\n const { _def } = router;\n let procedure = _def.procedures[path];\n\n while (!procedure) {\n const key = Object.keys(_def.lazy).find(\n (key) => path === key || path.startsWith(key + '.'),\n );\n // console.log(`found lazy: ${key ?? 'NOPE'} (fullPath: ${fullPath})`);\n\n if (!key) {\n return null;\n }\n // console.log('loading', key, '.......');\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const lazyRouter = _def.lazy[key]!;\n await lazyRouter.load();\n\n procedure = _def.procedures[path];\n }\n\n return procedure;\n}\n\n/**\n * Calls the procedure at `path`, throwing `NOT_FOUND` if there's none of\n * that type.\n * @internal\n */\nexport async function callProcedure(\n opts: ProcedureCallOptions<unknown> & {\n router: AnyRouter;\n allowMethodOverride?: boolean;\n },\n) {\n const { type, path } = opts;\n const proc = await getProcedureAtPath(opts.router, path);\n if (\n !proc ||\n !isProcedure(proc) ||\n (proc._def.type !== type && !opts.allowMethodOverride)\n ) {\n throw new TRPCError({\n code: 'NOT_FOUND',\n message: `No \"${type}\"-procedure on path \"${path}\"`,\n });\n }\n\n /* istanbul ignore if -- @preserve */\n if (\n proc._def.type !== type &&\n opts.allowMethodOverride &&\n proc._def.type === 'subscription'\n ) {\n throw new TRPCError({\n code: 'METHOD_NOT_SUPPORTED',\n message: `Method override is not supported for subscriptions`,\n });\n }\n\n return proc(opts);\n}\n\n/**\n * The type of `t.createCallerFactory()`: takes a router and returns its\n * `createCaller`.\n * @see https://trpc.io/docs/server/server-side-calls#create-caller\n */\nexport interface RouterCallerFactory<TRoot extends AnyRootTypes> {\n <TRecord extends RouterRecord>(\n router: Pick<Router<TRoot, TRecord>, '_def'>,\n ): RouterCaller<TRoot, TRecord>;\n}\n\nexport function createCallerFactory<\n TRoot extends AnyRootTypes,\n>(): RouterCallerFactory<TRoot> {\n return function createCallerInner<TRecord extends RouterRecord>(\n router: Pick<Router<TRoot, TRecord>, '_def'>,\n ): RouterCaller<TRoot, TRecord> {\n const { _def } = router;\n type Context = TRoot['ctx'];\n\n return function createCaller(ctxOrCallback, opts) {\n return createRecursiveProxy<ReturnType<RouterCaller<any, any>>>(\n async (innerOpts) => {\n const { path, args } = innerOpts;\n const fullPath = path.join('.');\n\n if (path.length === 1 && path[0] === '_def') {\n return _def;\n }\n\n const procedure = await getProcedureAtPath(router, fullPath);\n\n let ctx: Context | undefined = undefined;\n try {\n if (!procedure) {\n throw new TRPCError({\n code: 'NOT_FOUND',\n message: `No procedure found on path \"${path}\"`,\n });\n }\n ctx = isFunction(ctxOrCallback)\n ? await Promise.resolve(ctxOrCallback())\n : ctxOrCallback;\n\n return await procedure({\n path: fullPath,\n getRawInput: async () => args[0],\n ctx,\n type: procedure._def.type,\n signal: opts?.signal,\n batchIndex: 0,\n });\n } catch (cause) {\n opts?.onError?.({\n ctx,\n error: getTRPCErrorFromUnknown(cause),\n input: args[0],\n path: fullPath,\n type: procedure?._def.type ?? 'unknown',\n });\n throw cause;\n }\n },\n );\n };\n };\n}\n\n/**\n * The router `t.mergeRouters()` returns.\n * @internal\n */\nexport type MergeRouters<\n TRouters extends AnyRouter[],\n TRoot extends AnyRootTypes = TRouters[0]['_def']['_config']['$types'],\n TRecord extends RouterRecord = {},\n> = TRouters extends [\n infer Head extends AnyRouter,\n ...infer Tail extends AnyRouter[],\n]\n ? MergeRouters<Tail, TRoot, Head['_def']['record'] & TRecord>\n : BuiltRouter<TRoot, TRecord>;\n\nexport function mergeRouters<TRouters extends AnyRouter[]>(\n ...routerList: [...TRouters]\n): MergeRouters<TRouters> {\n const record = mergeWithoutOverrides(\n {},\n ...[...new Set(routerList)].map((r) => getRouterInput(r)),\n );\n const errorFormatter = routerList.reduce(\n (currentErrorFormatter, nextRouter) => {\n if (\n nextRouter._def._config.errorFormatter &&\n nextRouter._def._config.errorFormatter !== defaultFormatter\n ) {\n if (\n currentErrorFormatter !== defaultFormatter &&\n currentErrorFormatter !== nextRouter._def._config.errorFormatter\n ) {\n throw new Error('You seem to have several error formatters');\n }\n return nextRouter._def._config.errorFormatter;\n }\n return currentErrorFormatter;\n },\n defaultFormatter,\n );\n\n const transformer = routerList.reduce((prev, current) => {\n if (\n current._def._config.transformer &&\n current._def._config.transformer !== defaultTransformer\n ) {\n if (\n prev !== defaultTransformer &&\n prev !== current._def._config.transformer\n ) {\n throw new Error('You seem to have several transformers');\n }\n return current._def._config.transformer;\n }\n return prev;\n }, defaultTransformer);\n\n const pathSeparator = routerList.reduce<PathSeparator>((prev, current) => {\n const next = current._def._config.pathSeparator;\n if (next === '.') {\n return prev;\n }\n if (prev !== '.' && prev !== next) {\n throw new Error('You seem to have several pathSeparators');\n }\n return next;\n }, '.');\n\n const router = createRouterFactory({\n errorFormatter,\n transformer,\n pathSeparator,\n isDev: routerList.every((r) => r._def._config.isDev),\n allowOutsideOfServer: routerList.every(\n (r) => r._def._config.allowOutsideOfServer,\n ),\n isServer: routerList.every((r) => r._def._config.isServer),\n $types: routerList[0]?._def._config.$types,\n sse: routerList[0]?._def._config.sse,\n })(record);\n\n return router as MergeRouters<TRouters>;\n}\n","/**\n * The character between a procedure path's segments in HTTP URLs, such as\n * the `~` in `/trpc/post~byId`. Procedure paths stay dotted everywhere else:\n * in middlewares, errors, `onError` and query keys.\n *\n * These are the URL \"unreserved\" punctuation characters (RFC 3986), which\n * are never percent-encoded or normalised and mean nothing to routers. `/`\n * would need catch-all routes in every adapter, and `,` separates batched\n * calls.\n */\nexport type PathSeparator = '.' | '_' | '~' | '-';\n\n/**\n * Applies the `'.'` default to a user-given `pathSeparator` option. Call it\n * once, where the option is read.\n * @internal\n */\nexport function resolvePathSeparator(\n value: PathSeparator | undefined,\n): PathSeparator {\n return value ?? '.';\n}\n\n/**\n * `post.byId` → `post~byId`, for building URLs.\n * @internal\n */\nexport function procedurePathToURLPath(\n path: string,\n separator: PathSeparator,\n): string {\n if (separator === '.') {\n return path;\n }\n return path.split('.').join(separator);\n}\n\n/**\n * `post~byId` → `post.byId`, for reading URLs. Dotted paths still resolve,\n * so clients can move to the separator after the server does.\n * @internal\n */\nexport function urlPathToProcedurePath(\n path: string,\n separator: PathSeparator,\n): string {\n if (separator === '.') {\n return path;\n }\n return path.split(separator).join('.');\n}\n","const trackedSymbol = Symbol();\n\ntype TrackedId = string & {\n __brand: 'TrackedId';\n};\n/** An event wrapped by `tracked()`, with its id. */\nexport type TrackedEnvelope<TData> = [TrackedId, TData, typeof trackedSymbol];\n\n/** A tracked event as the client gets it. */\nexport interface TrackedData<TData> {\n /**\n * The event's id, which the client sends back as `lastEventId` when it\n * reconnects.\n */\n id: string;\n /**\n * The event's data.\n */\n data: TData;\n}\n/**\n * Wraps an event with an id, so a client can resume from it.\n * @deprecated Use `tracked(id, data)` instead.\n */\nexport function sse<TData>(event: { id: string; data: TData }) {\n return tracked(event.id, event.data);\n}\n\n/** Whether a value was made by `tracked()`. */\nexport function isTrackedEnvelope<TData>(\n value: unknown,\n): value is TrackedEnvelope<TData> {\n return Array.isArray(value) && value[2] === trackedSymbol;\n}\n\n/**\n * Gives a subscription event an id. When the connection drops, the client\n * reconnects with the last id it got, as `input.lastEventId`, so the\n * subscription can resume from there. The id can't be empty.\n * @example\n * ```ts\n * yield tracked(post.id, post);\n * ```\n * @see https://trpc.io/docs/server/subscriptions#tracked\n */\nexport function tracked<TData>(\n id: string,\n data: TData,\n): TrackedEnvelope<TData> {\n if (id === '') {\n // This limitation could be removed by using different SSE event names / channels for tracked event and non-tracked event\n throw new Error(\n '`id` must not be an empty string as empty string is the same as not setting the id at all',\n );\n }\n if (/[\\0\\n\\r]/.test(id)) {\n throw new Error(\n '`id` must not contain line breaks or null characters as they are not allowed in a Server-Sent Events id',\n );\n }\n return [id as TrackedId, data, trackedSymbol];\n}\n\n/** The type a client gets for an event, unwrapping `tracked()` events. */\nexport type inferTrackedOutput<TData> =\n TData extends TrackedEnvelope<infer $Data> ? TrackedData<$Data> : TData;\n"],"mappings":";;;AAGA,IAAM,oBAAN,cAA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OACiC;CACjC,OAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAO;AAC9C;;;;;;;;;;;AAYA,SAAgB,QACd,IACA,MACwB;CACxB,IAAI,OAAO,IAET,MAAM,IAAI,MACR,2FACF;CAEF,IAAI,WAAW,KAAK,EAAE,GACpB,MAAM,IAAI,MACR,yGACF;CAEF,OAAO;EAAC;EAAiB;EAAM;CAAa;AAC9C"}
@@ -1,6 +1,6 @@
1
- const require_codes = require("./codes-Be-DrYMh.cjs");
2
- const require_getErrorShape = require("./getErrorShape-BAuHhNuh.cjs");
3
- //#region src/unstable-core-do-not-import/error/TRPCError.ts
1
+ const require_codes = require("./codes-B96YeNnY.cjs");
2
+ const require_getErrorShape = require("./getErrorShape-B1AlrJBV.cjs");
3
+ // src/unstable-core-do-not-import/error/TRPCError.ts
4
4
  var UnknownCauseError = class extends Error {
5
5
  constructor(cause) {
6
6
  super(getMessage(cause));
@@ -65,8 +65,7 @@ var TRPCError = class extends Error {
65
65
  (_this$cause = this.cause) !== null && _this$cause !== void 0 || (this.cause = cause);
66
66
  }
67
67
  };
68
- //#endregion
69
- //#region src/unstable-core-do-not-import/transformer.ts
68
+ // src/unstable-core-do-not-import/transformer.ts
70
69
  /**
71
70
  * @internal
72
71
  */
@@ -139,8 +138,7 @@ function transformResult(response, transformer) {
139
138
  if (result.ok && !require_codes.isObject(result.result)) throw new TransformResultError();
140
139
  return result;
141
140
  }
142
- //#endregion
143
- //#region src/unstable-core-do-not-import/router.ts
141
+ // src/unstable-core-do-not-import/router.ts
144
142
  /**
145
143
  * @internal
146
144
  */
@@ -381,8 +379,7 @@ function mergeRouters(...routerList) {
381
379
  sse: (_routerList$2 = routerList[0]) === null || _routerList$2 === void 0 ? void 0 : _routerList$2._def._config.sse
382
380
  })(record);
383
381
  }
384
- //#endregion
385
- //#region src/unstable-core-do-not-import/http/pathSeparator.ts
382
+ // src/unstable-core-do-not-import/http/pathSeparator.ts
386
383
  /**
387
384
  * Applies the `'.'` default to a user-given `pathSeparator` option. Call it
388
385
  * once, where the option is read.
@@ -408,65 +405,51 @@ function urlPathToProcedurePath(path, separator) {
408
405
  if (separator === ".") return path;
409
406
  return path.split(separator).join(".");
410
407
  }
411
- //#endregion
412
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/OverloadYield.js
408
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/OverloadYield.js
413
409
  function _OverloadYield(e, d) {
414
410
  this.v = e, this.k = d;
415
411
  }
416
- //#endregion
417
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/wrapAsyncGenerator.js
412
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/wrapAsyncGenerator.js
418
413
  function _wrapAsyncGenerator(e) {
419
414
  return function() {
420
415
  return new AsyncGenerator(e.apply(this, arguments));
421
416
  };
422
417
  }
423
418
  function AsyncGenerator(e) {
424
- var r, t;
425
- function resume(r, t) {
419
+ var t, n;
420
+ function resume(t, n) {
426
421
  try {
427
- var n = e[r](t), o = n.value, u = o instanceof _OverloadYield;
428
- Promise.resolve(u ? o.v : o).then(function(t) {
422
+ var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
423
+ Promise.resolve(u ? o.v : o).then(function(n) {
429
424
  if (u) {
430
- var i = "return" === r ? "return" : "next";
431
- if (!o.k || t.done) return resume(i, t);
432
- t = e[i](t).value;
425
+ var i = "return" === t && o.k ? t : "next";
426
+ if (!o.k || n.done) return resume(i, n);
427
+ n = e[i](n).value;
433
428
  }
434
- settle(n.done ? "return" : "normal", t);
429
+ settle(!!r.done, n);
435
430
  }, function(e) {
436
431
  resume("throw", e);
437
432
  });
438
433
  } catch (e) {
439
- settle("throw", e);
434
+ settle(2, e);
440
435
  }
441
436
  }
442
- function settle(e, n) {
443
- switch (e) {
444
- case "return":
445
- r.resolve({
446
- value: n,
447
- done: !0
448
- });
449
- break;
450
- case "throw":
451
- r.reject(n);
452
- break;
453
- default: r.resolve({
454
- value: n,
455
- done: !1
456
- });
457
- }
458
- (r = r.next) ? resume(r.key, r.arg) : t = null;
437
+ function settle(e, r) {
438
+ 2 === e ? t.reject(r) : t.resolve({
439
+ value: r,
440
+ done: e
441
+ }), (t = t.next) ? resume(t.key, t.arg) : n = null;
459
442
  }
460
- this._invoke = function(e, n) {
443
+ this._invoke = function(e, r) {
461
444
  return new Promise(function(o, u) {
462
445
  var i = {
463
446
  key: e,
464
- arg: n,
447
+ arg: r,
465
448
  resolve: o,
466
449
  reject: u,
467
450
  next: null
468
451
  };
469
- t ? t = t.next = i : (r = t = i, resume(e, n));
452
+ n ? n = n.next = i : (t = n = i, resume(e, r));
470
453
  });
471
454
  }, "function" != typeof e["return"] && (this["return"] = void 0);
472
455
  }
@@ -479,8 +462,7 @@ AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator ||
479
462
  }, AsyncGenerator.prototype["return"] = function(e) {
480
463
  return this._invoke("return", e);
481
464
  };
482
- //#endregion
483
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/asyncIterator.js
465
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/asyncIterator.js
484
466
  function _asyncIterator(r) {
485
467
  var n, t, o, e = 2;
486
468
  for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
@@ -517,13 +499,12 @@ function AsyncFromSyncIterator(r) {
517
499
  }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
518
500
  },
519
501
  "throw": function _throw(r) {
520
- var n = this.s["return"];
502
+ var n = this.s["throw"];
521
503
  return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
522
504
  }
523
505
  }, new AsyncFromSyncIterator(r);
524
506
  }
525
- //#endregion
526
- //#region src/unstable-core-do-not-import/stream/tracked.ts
507
+ // src/unstable-core-do-not-import/stream/tracked.ts
527
508
  const trackedSymbol = Symbol();
528
509
  /**
529
510
  * Wraps an event with an id, so a client can resume from it.
@@ -555,8 +536,7 @@ function tracked(id, data) {
555
536
  trackedSymbol
556
537
  ];
557
538
  }
558
- //#endregion
559
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/asyncGeneratorDelegate.js
539
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/asyncGeneratorDelegate.js
560
540
  function _asyncGeneratorDelegate(t) {
561
541
  var e = {}, n = !1;
562
542
  function pump(e, r) {
@@ -578,7 +558,6 @@ function _asyncGeneratorDelegate(t) {
578
558
  return n ? (n = !1, t) : pump("return", t);
579
559
  }), e;
580
560
  }
581
- //#endregion
582
561
  Object.defineProperty(exports, "TRPCError", {
583
562
  enumerable: true,
584
563
  get: function() {
@@ -1,4 +1,4 @@
1
- //#region src/unstable-core-do-not-import/utils.ts
1
+ // src/unstable-core-do-not-import/utils.ts
2
2
  /**
3
3
  * Ensures there are no duplicate keys when building a procedure.
4
4
  * @internal
@@ -75,8 +75,7 @@ function abortSignalsAnyPonyfill(signals) {
75
75
  for (const signal of signals) signal.removeEventListener("abort", trigger);
76
76
  }
77
77
  }
78
- //#endregion
79
- //#region src/unstable-core-do-not-import/rpc/codes.ts
78
+ // src/unstable-core-do-not-import/rpc/codes.ts
80
79
  /**
81
80
  * The JSON-RPC 2.0 error code of each tRPC error code. tRPC's own codes
82
81
  * use the range JSON-RPC leaves for servers, `-32000` to `-32099`, ending
@@ -146,7 +145,6 @@ const retryableRpcCodes = [
146
145
  TRPC_ERROR_CODES_BY_KEY.GATEWAY_TIMEOUT,
147
146
  TRPC_ERROR_CODES_BY_KEY.INTERNAL_SERVER_ERROR
148
147
  ];
149
- //#endregion
150
148
  Object.defineProperty(exports, "TRPC_ERROR_CODES_BY_KEY", {
151
149
  enumerable: true,
152
150
  get: function() {
@@ -1,4 +1,4 @@
1
- //#region src/unstable-core-do-not-import/utils.ts
1
+ // src/unstable-core-do-not-import/utils.ts
2
2
  /**
3
3
  * Ensures there are no duplicate keys when building a procedure.
4
4
  * @internal
@@ -75,8 +75,7 @@ function abortSignalsAnyPonyfill(signals) {
75
75
  for (const signal of signals) signal.removeEventListener("abort", trigger);
76
76
  }
77
77
  }
78
- //#endregion
79
- //#region src/unstable-core-do-not-import/rpc/codes.ts
78
+ // src/unstable-core-do-not-import/rpc/codes.ts
80
79
  /**
81
80
  * The JSON-RPC 2.0 error code of each tRPC error code. tRPC's own codes
82
81
  * use the range JSON-RPC leaves for servers, `-32000` to `-32099`, ending
@@ -146,8 +145,7 @@ const retryableRpcCodes = [
146
145
  TRPC_ERROR_CODES_BY_KEY.GATEWAY_TIMEOUT,
147
146
  TRPC_ERROR_CODES_BY_KEY.INTERNAL_SERVER_ERROR
148
147
  ];
149
- //#endregion
150
148
  export { assert as a, identity as c, isObject as d, mergeWithoutOverrides as f, sleep as h, abortSignalsAnyPonyfill as i, isAsyncIterable as l, run as m, TRPC_ERROR_CODES_BY_NUMBER as n, assertNever as o, noop as p, retryableRpcCodes as r, emptyObject as s, TRPC_ERROR_CODES_BY_KEY as t, isFunction as u };
151
149
 
152
150
 
153
- //# sourceMappingURL=codes-nbrm_zWY.mjs.map
151
+ //# sourceMappingURL=codes-BCsCCyMj.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"codes-nbrm_zWY.mjs","names":[],"sources":["../src/unstable-core-do-not-import/utils.ts","../src/unstable-core-do-not-import/rpc/codes.ts"],"sourcesContent":["/**\n * Marks a type a procedure builder hasn't set yet, such as its input.\n * @internal\n */\nexport type UnsetMarker = 'unsetMarker' & {\n __brand: 'unsetMarker';\n};\n\n/**\n * Ensures there are no duplicate keys when building a procedure.\n * @internal\n */\nexport function mergeWithoutOverrides<TType extends Record<string, unknown>>(\n obj1: TType,\n ...objs: Partial<TType>[]\n): TType {\n const newObj: TType = Object.assign(emptyObject(), obj1);\n\n for (const overrides of objs) {\n for (const key in overrides) {\n if (key in newObj && newObj[key] !== overrides[key]) {\n throw new Error(`Duplicate key ${key}`);\n }\n newObj[key as keyof TType] = overrides[key] as TType[keyof TType];\n }\n }\n return newObj;\n}\n\n/**\n * Check that value is object\n * @internal\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return !!value && !Array.isArray(value) && typeof value === 'object';\n}\n\ntype AnyFn = ((...args: any[]) => unknown) & Record<keyof any, unknown>;\nexport function isFunction(fn: unknown): fn is AnyFn {\n return typeof fn === 'function';\n}\n\n/**\n * Create an object without inheriting anything from `Object.prototype`\n * @internal\n */\nexport function emptyObject<TObj extends Record<string, unknown>>(): TObj {\n return Object.create(null);\n}\n\nconst asyncIteratorsSupported =\n typeof Symbol === 'function' && !!Symbol.asyncIterator;\n\nexport function isAsyncIterable<TValue>(\n value: unknown,\n): value is AsyncIterable<TValue> {\n return (\n asyncIteratorsSupported && isObject(value) && Symbol.asyncIterator in value\n );\n}\n\n/**\n * Run an IIFE\n */\nexport const run = <TValue>(fn: () => TValue): TValue => fn();\n\n// oxlint-disable-next-line typescript/no-empty-function\nexport function noop(): void {}\n\nexport function identity<T>(it: T): T {\n return it;\n}\n\n/**\n * Generic runtime assertion function. Throws, if the condition is not `true`.\n *\n * Can be used as a slightly less dangerous variant of type assertions. Code\n * mistakes would be revealed at runtime then (hopefully during testing).\n */\nexport function assert(\n condition: boolean,\n msg = 'no additional info',\n): asserts condition {\n if (!condition) {\n throw new Error(`AssertionError: ${msg}`);\n }\n}\n\nexport function assertNever(value: never): never {\n throw new Error(`AssertionError: unexpected value ${String(value)}`);\n}\n\nexport function sleep(ms = 0): Promise<void> {\n return new Promise<void>((res) => setTimeout(res, ms));\n}\n\n/**\n * Ponyfill for\n * [`AbortSignal.any`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static).\n */\nexport function abortSignalsAnyPonyfill(signals: AbortSignal[]): AbortSignal {\n if (typeof AbortSignal.any === 'function') {\n return AbortSignal.any(signals);\n }\n\n const ac = new AbortController();\n\n for (const signal of signals) {\n if (signal.aborted) {\n trigger();\n break;\n }\n signal.addEventListener('abort', trigger, { once: true });\n }\n\n return ac.signal;\n\n function trigger() {\n ac.abort();\n for (const signal of signals) {\n signal.removeEventListener('abort', trigger);\n }\n }\n}\n","import type { InvertKeyValue, ValueOf } from '../types';\n\n// reference: https://www.jsonrpc.org/specification\n\n/**\n * The JSON-RPC 2.0 error code of each tRPC error code. tRPC's own codes\n * use the range JSON-RPC leaves for servers, `-32000` to `-32099`, ending\n * in the digits of the matching HTTP status.\n * @see https://trpc.io/docs/rpc#error-codes---json-rpc-20-error-codes\n */\nexport const TRPC_ERROR_CODES_BY_KEY = {\n /**\n * Invalid JSON was received by the server.\n * An error occurred on the server while parsing the JSON text.\n */\n PARSE_ERROR: -32700,\n /**\n * The JSON sent is not a valid Request object.\n */\n BAD_REQUEST: -32600, // 400\n\n // Internal JSON-RPC error\n INTERNAL_SERVER_ERROR: -32603, // 500\n NOT_IMPLEMENTED: -32603, // 501\n BAD_GATEWAY: -32603, // 502\n SERVICE_UNAVAILABLE: -32603, // 503\n GATEWAY_TIMEOUT: -32603, // 504\n\n // Implementation specific errors\n UNAUTHORIZED: -32001, // 401\n PAYMENT_REQUIRED: -32002, // 402\n FORBIDDEN: -32003, // 403\n NOT_FOUND: -32004, // 404\n METHOD_NOT_SUPPORTED: -32005, // 405\n TIMEOUT: -32008, // 408\n CONFLICT: -32009, // 409\n PRECONDITION_FAILED: -32012, // 412\n PAYLOAD_TOO_LARGE: -32013, // 413\n UNSUPPORTED_MEDIA_TYPE: -32015, // 415\n UNPROCESSABLE_CONTENT: -32022, // 422\n PRECONDITION_REQUIRED: -32028, // 428\n TOO_MANY_REQUESTS: -32029, // 429\n CLIENT_CLOSED_REQUEST: -32099, // 499\n} as const;\n\n/**\n * The tRPC error code of each JSON-RPC 2.0 error code.\n * @see https://trpc.io/docs/rpc#error-codes---json-rpc-20-error-codes\n */\nexport const TRPC_ERROR_CODES_BY_NUMBER: InvertKeyValue<\n typeof TRPC_ERROR_CODES_BY_KEY\n> = {\n [-32700]: 'PARSE_ERROR',\n [-32600]: 'BAD_REQUEST',\n [-32603]: 'INTERNAL_SERVER_ERROR',\n [-32001]: 'UNAUTHORIZED',\n [-32002]: 'PAYMENT_REQUIRED',\n [-32003]: 'FORBIDDEN',\n [-32004]: 'NOT_FOUND',\n [-32005]: 'METHOD_NOT_SUPPORTED',\n [-32008]: 'TIMEOUT',\n [-32009]: 'CONFLICT',\n [-32012]: 'PRECONDITION_FAILED',\n [-32013]: 'PAYLOAD_TOO_LARGE',\n [-32015]: 'UNSUPPORTED_MEDIA_TYPE',\n [-32022]: 'UNPROCESSABLE_CONTENT',\n [-32028]: 'PRECONDITION_REQUIRED',\n [-32029]: 'TOO_MANY_REQUESTS',\n [-32099]: 'CLIENT_CLOSED_REQUEST',\n};\n\n/** A JSON-RPC 2.0 error code tRPC sends, such as `-32004`. */\nexport type TRPC_ERROR_CODE_NUMBER = ValueOf<typeof TRPC_ERROR_CODES_BY_KEY>;\n/**\n * A tRPC error code, such as `'NOT_FOUND'`.\n * @see https://trpc.io/docs/server/error-handling#error-codes\n */\nexport type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;\n\n/**\n * tRPC error codes that are considered retryable\n * With out of the box SSE, the client will reconnect when these errors are encountered\n */\nexport const retryableRpcCodes: TRPC_ERROR_CODE_NUMBER[] = [\n TRPC_ERROR_CODES_BY_KEY.BAD_GATEWAY,\n TRPC_ERROR_CODES_BY_KEY.SERVICE_UNAVAILABLE,\n TRPC_ERROR_CODES_BY_KEY.GATEWAY_TIMEOUT,\n TRPC_ERROR_CODES_BY_KEY.INTERNAL_SERVER_ERROR,\n];\n"],"mappings":";;;;;AAYA,SAAgB,sBACd,MACA,GAAG,MACI;CACP,MAAM,SAAgB,OAAO,OAAO,YAAY,GAAG,IAAI;CAEvD,KAAK,MAAM,aAAa,MACtB,KAAK,MAAM,OAAO,WAAW;EAC3B,IAAI,OAAO,UAAU,OAAO,SAAS,UAAU,MAC7C,MAAM,IAAI,MAAM,iBAAiB,KAAK;EAExC,OAAO,OAAsB,UAAU;CACzC;CAEF,OAAO;AACT;;;;;AAMA,SAAgB,SAAS,OAAkD;CACzE,OAAO,CAAC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iBAAiB;CAGjB,cAAc;CACd,kBAAkB;CAClB,WAAW;CACX,WAAW;CACX,sBAAsB;CACtB,SAAS;CACT,UAAU;CACV,qBAAqB;CACrB,mBAAmB;CACnB,wBAAwB;CACxB,uBAAuB;CACvB,uBAAuB;CACvB,mBAAmB;CACnB,uBAAuB;AACzB;;;;;AAMA,MAAa,6BAET;EACD,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;AACZ;;;;;AAcA,MAAa,oBAA8C;CACzD,wBAAwB;CACxB,wBAAwB;CACxB,wBAAwB;CACxB,wBAAwB;AAC1B"}
1
+ {"version":3,"file":"codes-BCsCCyMj.mjs","names":[],"sources":["../src/unstable-core-do-not-import/utils.ts","../src/unstable-core-do-not-import/rpc/codes.ts"],"sourcesContent":["/**\n * Marks a type a procedure builder hasn't set yet, such as its input.\n * @internal\n */\nexport type UnsetMarker = 'unsetMarker' & {\n __brand: 'unsetMarker';\n};\n\n/**\n * Ensures there are no duplicate keys when building a procedure.\n * @internal\n */\nexport function mergeWithoutOverrides<TType extends Record<string, unknown>>(\n obj1: TType,\n ...objs: Partial<TType>[]\n): TType {\n const newObj: TType = Object.assign(emptyObject(), obj1);\n\n for (const overrides of objs) {\n for (const key in overrides) {\n if (key in newObj && newObj[key] !== overrides[key]) {\n throw new Error(`Duplicate key ${key}`);\n }\n newObj[key as keyof TType] = overrides[key] as TType[keyof TType];\n }\n }\n return newObj;\n}\n\n/**\n * Check that value is object\n * @internal\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return !!value && !Array.isArray(value) && typeof value === 'object';\n}\n\ntype AnyFn = ((...args: any[]) => unknown) & Record<keyof any, unknown>;\nexport function isFunction(fn: unknown): fn is AnyFn {\n return typeof fn === 'function';\n}\n\n/**\n * Create an object without inheriting anything from `Object.prototype`\n * @internal\n */\nexport function emptyObject<TObj extends Record<string, unknown>>(): TObj {\n return Object.create(null);\n}\n\nconst asyncIteratorsSupported =\n typeof Symbol === 'function' && !!Symbol.asyncIterator;\n\nexport function isAsyncIterable<TValue>(\n value: unknown,\n): value is AsyncIterable<TValue> {\n return (\n asyncIteratorsSupported && isObject(value) && Symbol.asyncIterator in value\n );\n}\n\n/**\n * Run an IIFE\n */\nexport const run = <TValue>(fn: () => TValue): TValue => fn();\n\n// oxlint-disable-next-line typescript/no-empty-function\nexport function noop(): void {}\n\nexport function identity<T>(it: T): T {\n return it;\n}\n\n/**\n * Generic runtime assertion function. Throws, if the condition is not `true`.\n *\n * Can be used as a slightly less dangerous variant of type assertions. Code\n * mistakes would be revealed at runtime then (hopefully during testing).\n */\nexport function assert(\n condition: boolean,\n msg = 'no additional info',\n): asserts condition {\n if (!condition) {\n throw new Error(`AssertionError: ${msg}`);\n }\n}\n\nexport function assertNever(value: never): never {\n throw new Error(`AssertionError: unexpected value ${String(value)}`);\n}\n\nexport function sleep(ms = 0): Promise<void> {\n return new Promise<void>((res) => setTimeout(res, ms));\n}\n\n/**\n * Ponyfill for\n * [`AbortSignal.any`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static).\n */\nexport function abortSignalsAnyPonyfill(signals: AbortSignal[]): AbortSignal {\n if (typeof AbortSignal.any === 'function') {\n return AbortSignal.any(signals);\n }\n\n const ac = new AbortController();\n\n for (const signal of signals) {\n if (signal.aborted) {\n trigger();\n break;\n }\n signal.addEventListener('abort', trigger, { once: true });\n }\n\n return ac.signal;\n\n function trigger() {\n ac.abort();\n for (const signal of signals) {\n signal.removeEventListener('abort', trigger);\n }\n }\n}\n","import type { InvertKeyValue, ValueOf } from '../types';\n\n// reference: https://www.jsonrpc.org/specification\n\n/**\n * The JSON-RPC 2.0 error code of each tRPC error code. tRPC's own codes\n * use the range JSON-RPC leaves for servers, `-32000` to `-32099`, ending\n * in the digits of the matching HTTP status.\n * @see https://trpc.io/docs/rpc#error-codes---json-rpc-20-error-codes\n */\nexport const TRPC_ERROR_CODES_BY_KEY = {\n /**\n * Invalid JSON was received by the server.\n * An error occurred on the server while parsing the JSON text.\n */\n PARSE_ERROR: -32700,\n /**\n * The JSON sent is not a valid Request object.\n */\n BAD_REQUEST: -32600, // 400\n\n // Internal JSON-RPC error\n INTERNAL_SERVER_ERROR: -32603, // 500\n NOT_IMPLEMENTED: -32603, // 501\n BAD_GATEWAY: -32603, // 502\n SERVICE_UNAVAILABLE: -32603, // 503\n GATEWAY_TIMEOUT: -32603, // 504\n\n // Implementation specific errors\n UNAUTHORIZED: -32001, // 401\n PAYMENT_REQUIRED: -32002, // 402\n FORBIDDEN: -32003, // 403\n NOT_FOUND: -32004, // 404\n METHOD_NOT_SUPPORTED: -32005, // 405\n TIMEOUT: -32008, // 408\n CONFLICT: -32009, // 409\n PRECONDITION_FAILED: -32012, // 412\n PAYLOAD_TOO_LARGE: -32013, // 413\n UNSUPPORTED_MEDIA_TYPE: -32015, // 415\n UNPROCESSABLE_CONTENT: -32022, // 422\n PRECONDITION_REQUIRED: -32028, // 428\n TOO_MANY_REQUESTS: -32029, // 429\n CLIENT_CLOSED_REQUEST: -32099, // 499\n} as const;\n\n/**\n * The tRPC error code of each JSON-RPC 2.0 error code.\n * @see https://trpc.io/docs/rpc#error-codes---json-rpc-20-error-codes\n */\nexport const TRPC_ERROR_CODES_BY_NUMBER: InvertKeyValue<\n typeof TRPC_ERROR_CODES_BY_KEY\n> = {\n [-32700]: 'PARSE_ERROR',\n [-32600]: 'BAD_REQUEST',\n [-32603]: 'INTERNAL_SERVER_ERROR',\n [-32001]: 'UNAUTHORIZED',\n [-32002]: 'PAYMENT_REQUIRED',\n [-32003]: 'FORBIDDEN',\n [-32004]: 'NOT_FOUND',\n [-32005]: 'METHOD_NOT_SUPPORTED',\n [-32008]: 'TIMEOUT',\n [-32009]: 'CONFLICT',\n [-32012]: 'PRECONDITION_FAILED',\n [-32013]: 'PAYLOAD_TOO_LARGE',\n [-32015]: 'UNSUPPORTED_MEDIA_TYPE',\n [-32022]: 'UNPROCESSABLE_CONTENT',\n [-32028]: 'PRECONDITION_REQUIRED',\n [-32029]: 'TOO_MANY_REQUESTS',\n [-32099]: 'CLIENT_CLOSED_REQUEST',\n};\n\n/** A JSON-RPC 2.0 error code tRPC sends, such as `-32004`. */\nexport type TRPC_ERROR_CODE_NUMBER = ValueOf<typeof TRPC_ERROR_CODES_BY_KEY>;\n/**\n * A tRPC error code, such as `'NOT_FOUND'`.\n * @see https://trpc.io/docs/server/error-handling#error-codes\n */\nexport type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;\n\n/**\n * tRPC error codes that are considered retryable\n * With out of the box SSE, the client will reconnect when these errors are encountered\n */\nexport const retryableRpcCodes: TRPC_ERROR_CODE_NUMBER[] = [\n TRPC_ERROR_CODES_BY_KEY.BAD_GATEWAY,\n TRPC_ERROR_CODES_BY_KEY.SERVICE_UNAVAILABLE,\n TRPC_ERROR_CODES_BY_KEY.GATEWAY_TIMEOUT,\n TRPC_ERROR_CODES_BY_KEY.INTERNAL_SERVER_ERROR,\n];\n"],"mappings":";;;;;AAYA,SAAgB,sBACd,MACA,GAAG,MACI;CACP,MAAM,SAAgB,OAAO,OAAO,YAAY,GAAG,IAAI;CAEvD,KAAK,MAAM,aAAa,MACtB,KAAK,MAAM,OAAO,WAAW;EAC3B,IAAI,OAAO,UAAU,OAAO,SAAS,UAAU,MAC7C,MAAM,IAAI,MAAM,iBAAiB,KAAK;EAExC,OAAO,OAAsB,UAAU;CACzC;CAEF,OAAO;AACT;;;;;AAMA,SAAgB,SAAS,OAAkD;CACzE,OAAO,CAAC,CAAC,SAAS,CAAC,MAAM,QAAQ,KAAK,KAAK,OAAO,UAAU;AAC9D;AAGA,SAAgB,WAAW,IAA0B;CACnD,OAAO,OAAO,OAAO;AACvB;;;;;AAMA,SAAgB,cAA0D;CACxE,OAAO,OAAO,OA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vB,mBAAmB;CACnB,uBAAuB;AACzB;;;;;AAMA,MAAa,6BAET;EACD,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;AACZ;;;;;AAcA,MAAa,oBAA8C;CACzD,wBAAwB;CACxB,wBAAwB;CACxB,wBAAwB;CACxB,wBAAwB;AAC1B"}
@@ -1,4 +1,4 @@
1
- //#region src/unstable-core-do-not-import/http/contentTypeParsers.ts
1
+ // src/unstable-core-do-not-import/http/contentTypeParsers.ts
2
2
  /**
3
3
  * An input validator for binary data, such as a `File` or `Blob`. The
4
4
  * resolver gets the input as a `ReadableStream`.
@@ -19,8 +19,7 @@ const octetInputParser = {
19
19
  throw new Error(`Parsed input was expected to be a ReadableStream but was: ${typeof input}`);
20
20
  }
21
21
  };
22
- //#endregion
23
22
  export { octetInputParser as t };
24
23
 
25
24
 
26
- //# sourceMappingURL=contentTypeParsers-D1EBkFFY.mjs.map
25
+ //# sourceMappingURL=contentTypeParsers-g-hK2Sqe.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contentTypeParsers-D1EBkFFY.mjs","names":[],"sources":["../src/unstable-core-do-not-import/http/contentTypeParsers.ts"],"sourcesContent":["import type { ParserZodEsque } from '../parser';\n\n/**\n * A validator tRPC ships for a special input type.\n * @internal\n */\nexport type UtilityParser<TInput, TOutput> = ParserZodEsque<TInput, TOutput> & {\n parse: (input: unknown) => TOutput;\n};\n\n// Should be the same possible types as packages/client/src/links/internals/contentTypes.ts isOctetType\n\n/**\n * A `File`. Node 18 has no `File` type, but a `File` is always a `Blob`.\n * @internal\n */\nexport interface FileLike extends Blob {\n readonly name: string;\n}\n\n/**\n * The binary inputs a client can send with `octetInputParser`.\n * @internal\n */\nexport type OctetInput = Blob | Uint8Array | FileLike;\n\n/**\n * An input validator for binary data, such as a `File` or `Blob`. The\n * resolver gets the input as a `ReadableStream`.\n * @example\n * ```ts\n * t.procedure.input(octetInputParser).mutation(async ({ input }) => {\n * const bytes = await new Response(input).arrayBuffer();\n * return { size: bytes.byteLength };\n * });\n * ```\n * @see https://trpc.io/docs/server/non-json-content-types#file-and-other-binary-type-inputs\n */\nexport const octetInputParser: UtilityParser<OctetInput, ReadableStream> = {\n _input: null as any as OctetInput,\n _output: null as any as ReadableStream,\n parse(input) {\n if (input instanceof ReadableStream) {\n return input;\n }\n\n throw new Error(\n `Parsed input was expected to be a ReadableStream but was: ${typeof input}`,\n );\n },\n};\n"],"mappings":";;;;;;;;;;;;;AAsCA,MAAa,mBAA8D;CACzE,QAAQ;CACR,SAAS;CACT,MAAM,OAAO;EACX,IAAI,iBAAiB,gBACnB,OAAO;EAGT,MAAM,IAAI,MACR,6DAA6D,OAAO,OACtE;CACF;AACF"}
1
+ {"version":3,"file":"contentTypeParsers-g-hK2Sqe.mjs","names":[],"sources":["../src/unstable-core-do-not-import/http/contentTypeParsers.ts"],"sourcesContent":["import type { ParserZodEsque } from '../parser';\n\n/**\n * A validator tRPC ships for a special input type.\n * @internal\n */\nexport type UtilityParser<TInput, TOutput> = ParserZodEsque<TInput, TOutput> & {\n parse: (input: unknown) => TOutput;\n};\n\n// Should be the same possible types as packages/client/src/links/internals/contentTypes.ts isOctetType\n\n/**\n * A `File`. Node 18 has no `File` type, but a `File` is always a `Blob`.\n * @internal\n */\nexport interface FileLike extends Blob {\n readonly name: string;\n}\n\n/**\n * The binary inputs a client can send with `octetInputParser`.\n * @internal\n */\nexport type OctetInput = Blob | Uint8Array | FileLike;\n\n/**\n * An input validator for binary data, such as a `File` or `Blob`. The\n * resolver gets the input as a `ReadableStream`.\n * @example\n * ```ts\n * t.procedure.input(octetInputParser).mutation(async ({ input }) => {\n * const bytes = await new Response(input).arrayBuffer();\n * return { size: bytes.byteLength };\n * });\n * ```\n * @see https://trpc.io/docs/server/non-json-content-types#file-and-other-binary-type-inputs\n */\nexport const octetInputParser: UtilityParser<OctetInput, ReadableStream> = {\n _input: null as any as OctetInput,\n _output: null as any as ReadableStream,\n parse(input) {\n if (input instanceof ReadableStream) {\n return input;\n }\n\n throw new Error(\n `Parsed input was expected to be a ReadableStream but was: ${typeof input}`,\n );\n },\n};\n"],"mappings":";;;;;;;;;;;;;AAsCA,MAAa,mBAA8D;CACzE,QAAQ;CACR,SAAS;CACT,MAAM,OAAO;EACX,IAAI,iBAAiB,gBACnB,OAAO;EAGT,MAAM,IAAI,MACR,6DAA6D,OAAO,OACtE;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- //#region src/unstable-core-do-not-import/http/contentTypeParsers.ts
1
+ // src/unstable-core-do-not-import/http/contentTypeParsers.ts
2
2
  /**
3
3
  * An input validator for binary data, such as a `File` or `Blob`. The
4
4
  * resolver gets the input as a `ReadableStream`.
@@ -19,7 +19,6 @@ const octetInputParser = {
19
19
  throw new Error(`Parsed input was expected to be a ReadableStream but was: ${typeof input}`);
20
20
  }
21
21
  };
22
- //#endregion
23
22
  Object.defineProperty(exports, "octetInputParser", {
24
23
  enumerable: true,
25
24
  get: function() {
@@ -1,5 +1,5 @@
1
- const require_codes = require("./codes-Be-DrYMh.cjs");
2
- //#region src/unstable-core-do-not-import/createProxy.ts
1
+ const require_codes = require("./codes-B96YeNnY.cjs");
2
+ // src/unstable-core-do-not-import/createProxy.ts
3
3
  const noop = () => {};
4
4
  const freezeIfAvailable = (obj) => {
5
5
  if (Object.freeze) Object.freeze(obj);
@@ -51,8 +51,7 @@ const createFlatProxy = (callback) => {
51
51
  return callback(name);
52
52
  } });
53
53
  };
54
- //#endregion
55
- //#region src/unstable-core-do-not-import/http/getHTTPStatusCode.ts
54
+ // src/unstable-core-do-not-import/http/getHTTPStatusCode.ts
56
55
  const JSONRPC2_TO_HTTP_CODE = {
57
56
  PARSE_ERROR: 400,
58
57
  BAD_REQUEST: 400,
@@ -132,8 +131,7 @@ function getHTTPStatusCode(json, errors) {
132
131
  function getHTTPStatusCodeFromError(error) {
133
132
  return getStatusCodeFromKey(error.code);
134
133
  }
135
- //#endregion
136
- //#region src/unstable-core-do-not-import/error/formatter.ts
134
+ // src/unstable-core-do-not-import/error/formatter.ts
137
135
  const defaultFormatter = ({ shape }) => {
138
136
  return shape;
139
137
  };
@@ -174,8 +172,7 @@ function getFormattedErrorShape(error) {
174
172
  function isFormattedErrorShape(error) {
175
173
  return formattedShapeSymbol in error;
176
174
  }
177
- //#endregion
178
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
175
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
179
176
  function _typeof(o) {
180
177
  "@babel/helpers - typeof";
181
178
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -184,26 +181,23 @@ function _typeof(o) {
184
181
  return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
185
182
  }, _typeof(o);
186
183
  }
187
- //#endregion
188
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
189
- function toPrimitive(t, r) {
184
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
185
+ function toPrimitive(t, e) {
190
186
  if ("object" != _typeof(t) || !t) return t;
191
- var e = t[Symbol.toPrimitive];
192
- if (void 0 !== e) {
193
- var i = e.call(t, r || "default");
187
+ var r;
188
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
189
+ var i = r.call(t, e || "default");
194
190
  if ("object" != _typeof(i)) return i;
195
191
  throw new TypeError("@@toPrimitive must return a primitive value.");
196
192
  }
197
- return ("string" === r ? String : Number)(t);
193
+ return ("string" === e ? String : Number)(t);
198
194
  }
199
- //#endregion
200
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
195
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
201
196
  function toPropertyKey(t) {
202
197
  var i = toPrimitive(t, "string");
203
198
  return "symbol" == _typeof(i) ? i : i + "";
204
199
  }
205
- //#endregion
206
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
200
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
207
201
  function _defineProperty(e, r, t) {
208
202
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
209
203
  value: t,
@@ -212,8 +206,7 @@ function _defineProperty(e, r, t) {
212
206
  writable: !0
213
207
  }) : e[r] = t, e;
214
208
  }
215
- //#endregion
216
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/objectSpread2.js
209
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/objectSpread2.js
217
210
  function ownKeys(e, r) {
218
211
  var t = Object.keys(e);
219
212
  if (Object.getOwnPropertySymbols) {
@@ -235,8 +228,7 @@ function _objectSpread2(e) {
235
228
  }
236
229
  return e;
237
230
  }
238
- //#endregion
239
- //#region src/unstable-core-do-not-import/error/getErrorShape.ts
231
+ // src/unstable-core-do-not-import/error/getErrorShape.ts
240
232
  /**
241
233
  * The shape of an error as the client gets it: from a procedure's
242
234
  * `.errors()` formatter if one ran, or else from the root error formatter.
@@ -253,7 +245,6 @@ function getErrorShape(opts) {
253
245
  });
254
246
  return config.errorFormatter(_objectSpread2(_objectSpread2({}, opts), {}, { shape }));
255
247
  }
256
- //#endregion
257
248
  Object.defineProperty(exports, "HTTP_CODE_TO_JSONRPC2", {
258
249
  enumerable: true,
259
250
  get: function() {