@orpc/server 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-ACLC6USM.js +262 -0
- package/dist/chunk-ACLC6USM.js.map +1 -0
- package/dist/fetch.js +648 -0
- package/dist/fetch.js.map +1 -0
- package/dist/index.js +403 -0
- package/dist/index.js.map +1 -0
- package/dist/src/adapters/fetch.d.ts +36 -0
- package/dist/src/adapters/fetch.d.ts.map +1 -0
- package/dist/src/builder.d.ts +49 -0
- package/dist/src/builder.d.ts.map +1 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/middleware.d.ts +16 -0
- package/dist/src/middleware.d.ts.map +1 -0
- package/dist/src/procedure-builder.d.ts +31 -0
- package/dist/src/procedure-builder.d.ts.map +1 -0
- package/dist/src/procedure-caller.d.ts +33 -0
- package/dist/src/procedure-caller.d.ts.map +1 -0
- package/dist/src/procedure-implementer.d.ts +19 -0
- package/dist/src/procedure-implementer.d.ts.map +1 -0
- package/dist/src/procedure.d.ts +29 -0
- package/dist/src/procedure.d.ts.map +1 -0
- package/dist/src/router-builder.d.ts +22 -0
- package/dist/src/router-builder.d.ts.map +1 -0
- package/dist/src/router-caller.d.ts +36 -0
- package/dist/src/router-caller.d.ts.map +1 -0
- package/dist/src/router-implementer.d.ts +20 -0
- package/dist/src/router-implementer.d.ts.map +1 -0
- package/dist/src/router.d.ts +14 -0
- package/dist/src/router.d.ts.map +1 -0
- package/dist/src/types.d.ts +18 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/utils.d.ts +4 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +57 -0
- package/src/adapters/fetch.test.ts +399 -0
- package/src/adapters/fetch.ts +228 -0
- package/src/builder.test.ts +362 -0
- package/src/builder.ts +236 -0
- package/src/index.ts +16 -0
- package/src/middleware.test.ts +279 -0
- package/src/middleware.ts +119 -0
- package/src/procedure-builder.test.ts +219 -0
- package/src/procedure-builder.ts +158 -0
- package/src/procedure-caller.test.ts +210 -0
- package/src/procedure-caller.ts +165 -0
- package/src/procedure-implementer.test.ts +215 -0
- package/src/procedure-implementer.ts +103 -0
- package/src/procedure.test.ts +312 -0
- package/src/procedure.ts +251 -0
- package/src/router-builder.test.ts +106 -0
- package/src/router-builder.ts +120 -0
- package/src/router-caller.test.ts +173 -0
- package/src/router-caller.ts +95 -0
- package/src/router-implementer.test.ts +116 -0
- package/src/router-implementer.ts +110 -0
- package/src/router.test.ts +142 -0
- package/src/router.ts +69 -0
- package/src/types.test.ts +18 -0
- package/src/types.ts +28 -0
- package/src/utils.test.ts +243 -0
- package/src/utils.ts +95 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/adapters/fetch.ts","../../../node_modules/.pnpm/hono@4.6.6/node_modules/hono/dist/router.js","../../../node_modules/.pnpm/hono@4.6.6/node_modules/hono/dist/utils/url.js","../../../node_modules/.pnpm/hono@4.6.6/node_modules/hono/dist/router/linear-router/router.js","../../../node_modules/.pnpm/hono@4.6.6/node_modules/hono/dist/router/reg-exp-router/node.js","../../../node_modules/.pnpm/hono@4.6.6/node_modules/hono/dist/router/reg-exp-router/trie.js","../../../node_modules/.pnpm/hono@4.6.6/node_modules/hono/dist/router/reg-exp-router/router.js"],"sourcesContent":["/// <reference lib=\"dom\" />\n\nimport {\n type HTTPPath,\n ORPC_HEADER,\n ORPC_HEADER_VALUE,\n standardizeHTTPPath,\n} from '@orpc/contract'\nimport {\n type PartialOnUndefinedDeep,\n get,\n isPlainObject,\n trim,\n} from '@orpc/shared'\nimport { ORPCError } from '@orpc/shared/error'\nimport {\n ORPCDeserializer,\n ORPCSerializer,\n OpenAPIDeserializer,\n OpenAPISerializer,\n} from '@orpc/transformer'\nimport { LinearRouter } from 'hono/router/linear-router'\nimport { RegExpRouter } from 'hono/router/reg-exp-router'\nimport { type WELL_DEFINED_PROCEDURE, isProcedure } from '../procedure'\nimport { createProcedureCaller } from '../procedure-caller'\nimport type { Router } from '../router'\nimport type { Meta, Promisable } from '../types'\nimport { hook } from '../utils'\n\nexport interface CreateFetchHandlerOptions<TRouter extends Router<any>> {\n router: TRouter\n\n hooks?: (\n context: TRouter extends Router<infer UContext> ? UContext : never,\n meta: Meta<unknown>,\n ) => Promisable<void>\n\n /**\n * It will help improve the cold start time. But it will increase the performance.\n *\n * @default false\n */\n serverless?: boolean\n}\n\nexport function createFetchHandler<TRouter extends Router<any>>(\n options: CreateFetchHandlerOptions<TRouter>,\n): FetchHandler<TRouter> {\n const routing = options.serverless\n ? new LinearRouter<[string[], WELL_DEFINED_PROCEDURE]>()\n : new RegExpRouter<[string[], WELL_DEFINED_PROCEDURE]>()\n\n const addRouteRecursively = (router: Router<any>, basePath: string[]) => {\n for (const key in router) {\n const currentPath = [...basePath, key]\n const item = router[key] as WELL_DEFINED_PROCEDURE | Router<any>\n\n if (isProcedure(item)) {\n if (item.zz$p.contract.zz$cp.path) {\n const method = item.zz$p.contract.zz$cp.method ?? 'POST'\n const path = openAPIPathToRouterPath(item.zz$p.contract.zz$cp.path)\n\n routing.add(method, path, [currentPath, item])\n }\n } else {\n addRouteRecursively(item, currentPath)\n }\n }\n }\n\n addRouteRecursively(options.router, [])\n\n return async (requestOptions) => {\n const isORPCTransformer =\n requestOptions.request.headers.get(ORPC_HEADER) === ORPC_HEADER_VALUE\n const accept = requestOptions.request.headers.get('Accept') ?? undefined\n\n const serializer = isORPCTransformer\n ? new ORPCSerializer()\n : new OpenAPISerializer({ accept })\n\n try {\n return await hook(async (hooks) => {\n const url = new URL(requestOptions.request.url)\n const pathname = `/${trim(url.pathname.replace(requestOptions.prefix ?? '', ''), '/')}`\n\n let path: string[] | undefined\n let procedure: WELL_DEFINED_PROCEDURE | undefined\n let params: Record<string, string | number> | undefined\n\n if (isORPCTransformer) {\n path = trim(pathname, '/').split('/').map(decodeURIComponent)\n const val = get(options.router, path)\n\n if (isProcedure(val)) {\n procedure = val\n }\n } else {\n const [[match]] = routing.match(\n requestOptions.request.method,\n pathname,\n )\n path = match?.[0][0]\n procedure = match?.[0][1]\n params = match?.[1]\n\n if (!path || !procedure) {\n path = trim(pathname, '/').split('/').map(decodeURIComponent)\n\n const val = get(options.router, path)\n\n if (isProcedure(val)) {\n procedure = val\n }\n }\n }\n\n if (!path || !procedure) {\n throw new ORPCError({ code: 'NOT_FOUND', message: 'Not found' })\n }\n\n const meta: Meta<unknown> = {\n ...hooks,\n procedure,\n path: path,\n internal: false,\n }\n\n await options.hooks?.(requestOptions.context as any, meta)\n\n const deserializer = isORPCTransformer\n ? new ORPCDeserializer()\n : new OpenAPIDeserializer({\n schema: procedure.zz$p.contract.zz$cp.InputSchema,\n })\n\n const input_ = await (async () => {\n try {\n return await deserializer.deserialize(requestOptions.request)\n } catch (e) {\n throw new ORPCError({\n code: 'BAD_REQUEST',\n message:\n 'Cannot parse request. Please check the request body and Content-Type header.',\n cause: e,\n })\n }\n })()\n\n const input = (() => {\n if (\n params &&\n Object.keys(params).length > 0 &&\n (input_ === undefined || isPlainObject(input_))\n ) {\n return {\n ...params,\n ...input_,\n }\n }\n\n return input_\n })()\n\n const caller = createProcedureCaller({\n context: requestOptions.context,\n internal: false,\n validate: true,\n procedure,\n path,\n })\n\n const output = await caller(input)\n\n const { body, headers } = serializer.serialize(output)\n\n return new Response(body, {\n status: 200,\n headers,\n })\n })\n } catch (e) {\n const error =\n e instanceof ORPCError\n ? e\n : new ORPCError({\n code: 'INTERNAL_SERVER_ERROR',\n message: 'Internal server error',\n cause: e,\n })\n\n const { body, headers } = serializer.serialize(error.toJSON())\n\n return new Response(body, {\n status: error.status,\n headers: headers,\n })\n }\n }\n}\n\nfunction openAPIPathToRouterPath(path: HTTPPath): string {\n return standardizeHTTPPath(path).replace(/\\{([^}]+)\\}/g, ':$1')\n}\n\nexport type FetchHandlerOptions<TRouter extends Router<any>> = {\n /**\n * The request need to be handled.\n */\n request: Request\n\n /**\n * Remove the prefix from the request path.\n *\n * @example /orpc\n * @example /api\n */\n prefix?: string\n} & PartialOnUndefinedDeep<{\n /**\n * The context used to handle the request.\n */\n context: TRouter extends Router<infer UContext> ? UContext : never\n}>\n\nexport interface FetchHandler<TRouter extends Router<any>> {\n (options: FetchHandlerOptions<TRouter>): Promise<Response>\n}\n","// src/router.ts\nvar METHOD_NAME_ALL = \"ALL\";\nvar METHOD_NAME_ALL_LOWERCASE = \"all\";\nvar METHODS = [\"get\", \"post\", \"put\", \"delete\", \"options\", \"patch\"];\nvar MESSAGE_MATCHER_IS_ALREADY_BUILT = \"Can not add a route since the matcher is already built.\";\nvar UnsupportedPathError = class extends Error {\n};\nexport {\n MESSAGE_MATCHER_IS_ALREADY_BUILT,\n METHODS,\n METHOD_NAME_ALL,\n METHOD_NAME_ALL_LOWERCASE,\n UnsupportedPathError\n};\n","// src/utils/url.ts\nvar splitPath = (path) => {\n const paths = path.split(\"/\");\n if (paths[0] === \"\") {\n paths.shift();\n }\n return paths;\n};\nvar splitRoutingPath = (routePath) => {\n const { groups, path } = extractGroupsFromPath(routePath);\n const paths = splitPath(path);\n return replaceGroupMarks(paths, groups);\n};\nvar extractGroupsFromPath = (path) => {\n const groups = [];\n path = path.replace(/\\{[^}]+\\}/g, (match, index) => {\n const mark = `@${index}`;\n groups.push([mark, match]);\n return mark;\n });\n return { groups, path };\n};\nvar replaceGroupMarks = (paths, groups) => {\n for (let i = groups.length - 1; i >= 0; i--) {\n const [mark] = groups[i];\n for (let j = paths.length - 1; j >= 0; j--) {\n if (paths[j].includes(mark)) {\n paths[j] = paths[j].replace(mark, groups[i][1]);\n break;\n }\n }\n }\n return paths;\n};\nvar patternCache = {};\nvar getPattern = (label) => {\n if (label === \"*\") {\n return \"*\";\n }\n const match = label.match(/^\\:([^\\{\\}]+)(?:\\{(.+)\\})?$/);\n if (match) {\n if (!patternCache[label]) {\n if (match[2]) {\n patternCache[label] = [label, match[1], new RegExp(\"^\" + match[2] + \"$\")];\n } else {\n patternCache[label] = [label, match[1], true];\n }\n }\n return patternCache[label];\n }\n return null;\n};\nvar tryDecodeURI = (str) => {\n try {\n return decodeURI(str);\n } catch {\n return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match) => {\n try {\n return decodeURI(match);\n } catch {\n return match;\n }\n });\n }\n};\nvar getPath = (request) => {\n const url = request.url;\n const start = url.indexOf(\"/\", 8);\n let i = start;\n for (; i < url.length; i++) {\n const charCode = url.charCodeAt(i);\n if (charCode === 37) {\n const queryIndex = url.indexOf(\"?\", i);\n const path = url.slice(start, queryIndex === -1 ? void 0 : queryIndex);\n return tryDecodeURI(path.includes(\"%25\") ? path.replace(/%25/g, \"%2525\") : path);\n } else if (charCode === 63) {\n break;\n }\n }\n return url.slice(start, i);\n};\nvar getQueryStrings = (url) => {\n const queryIndex = url.indexOf(\"?\", 8);\n return queryIndex === -1 ? \"\" : \"?\" + url.slice(queryIndex + 1);\n};\nvar getPathNoStrict = (request) => {\n const result = getPath(request);\n return result.length > 1 && result[result.length - 1] === \"/\" ? result.slice(0, -1) : result;\n};\nvar mergePath = (...paths) => {\n let p = \"\";\n let endsWithSlash = false;\n for (let path of paths) {\n if (p[p.length - 1] === \"/\") {\n p = p.slice(0, -1);\n endsWithSlash = true;\n }\n if (path[0] !== \"/\") {\n path = `/${path}`;\n }\n if (path === \"/\" && endsWithSlash) {\n p = `${p}/`;\n } else if (path !== \"/\") {\n p = `${p}${path}`;\n }\n if (path === \"/\" && p === \"\") {\n p = \"/\";\n }\n }\n return p;\n};\nvar checkOptionalParameter = (path) => {\n if (!path.match(/\\:.+\\?$/)) {\n return null;\n }\n const segments = path.split(\"/\");\n const results = [];\n let basePath = \"\";\n segments.forEach((segment) => {\n if (segment !== \"\" && !/\\:/.test(segment)) {\n basePath += \"/\" + segment;\n } else if (/\\:/.test(segment)) {\n if (/\\?/.test(segment)) {\n if (results.length === 0 && basePath === \"\") {\n results.push(\"/\");\n } else {\n results.push(basePath);\n }\n const optionalSegment = segment.replace(\"?\", \"\");\n basePath += \"/\" + optionalSegment;\n results.push(basePath);\n } else {\n basePath += \"/\" + segment;\n }\n }\n });\n return results.filter((v, i, a) => a.indexOf(v) === i);\n};\nvar _decodeURI = (value) => {\n if (!/[%+]/.test(value)) {\n return value;\n }\n if (value.indexOf(\"+\") !== -1) {\n value = value.replace(/\\+/g, \" \");\n }\n return /%/.test(value) ? decodeURIComponent_(value) : value;\n};\nvar _getQueryParam = (url, key, multiple) => {\n let encoded;\n if (!multiple && key && !/[%+]/.test(key)) {\n let keyIndex2 = url.indexOf(`?${key}`, 8);\n if (keyIndex2 === -1) {\n keyIndex2 = url.indexOf(`&${key}`, 8);\n }\n while (keyIndex2 !== -1) {\n const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);\n if (trailingKeyCode === 61) {\n const valueIndex = keyIndex2 + key.length + 2;\n const endIndex = url.indexOf(\"&\", valueIndex);\n return _decodeURI(url.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));\n } else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) {\n return \"\";\n }\n keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);\n }\n encoded = /[%+]/.test(url);\n if (!encoded) {\n return void 0;\n }\n }\n const results = {};\n encoded ??= /[%+]/.test(url);\n let keyIndex = url.indexOf(\"?\", 8);\n while (keyIndex !== -1) {\n const nextKeyIndex = url.indexOf(\"&\", keyIndex + 1);\n let valueIndex = url.indexOf(\"=\", keyIndex);\n if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) {\n valueIndex = -1;\n }\n let name = url.slice(\n keyIndex + 1,\n valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex\n );\n if (encoded) {\n name = _decodeURI(name);\n }\n keyIndex = nextKeyIndex;\n if (name === \"\") {\n continue;\n }\n let value;\n if (valueIndex === -1) {\n value = \"\";\n } else {\n value = url.slice(valueIndex + 1, nextKeyIndex === -1 ? void 0 : nextKeyIndex);\n if (encoded) {\n value = _decodeURI(value);\n }\n }\n if (multiple) {\n if (!(results[name] && Array.isArray(results[name]))) {\n results[name] = [];\n }\n ;\n results[name].push(value);\n } else {\n results[name] ??= value;\n }\n }\n return key ? results[key] : results;\n};\nvar getQueryParam = _getQueryParam;\nvar getQueryParams = (url, key) => {\n return _getQueryParam(url, key, true);\n};\nvar decodeURIComponent_ = decodeURIComponent;\nexport {\n checkOptionalParameter,\n decodeURIComponent_,\n getPath,\n getPathNoStrict,\n getPattern,\n getQueryParam,\n getQueryParams,\n getQueryStrings,\n mergePath,\n splitPath,\n splitRoutingPath\n};\n","// src/router/linear-router/router.ts\nimport { METHOD_NAME_ALL, UnsupportedPathError } from \"../../router.js\";\nimport { checkOptionalParameter } from \"../../utils/url.js\";\nvar emptyParams = /* @__PURE__ */ Object.create(null);\nvar splitPathRe = /\\/(:\\w+(?:{(?:(?:{[\\d,]+})|[^}])+})?)|\\/[^\\/\\?]+|(\\?)/g;\nvar splitByStarRe = /\\*/;\nvar LinearRouter = class {\n name = \"LinearRouter\";\n routes = [];\n add(method, path, handler) {\n ;\n (checkOptionalParameter(path) || [path]).forEach((p) => {\n this.routes.push([method, p, handler]);\n });\n }\n match(method, path) {\n const handlers = [];\n ROUTES_LOOP:\n for (let i = 0, len = this.routes.length; i < len; i++) {\n const [routeMethod, routePath, handler] = this.routes[i];\n if (routeMethod !== method && routeMethod !== METHOD_NAME_ALL) {\n continue;\n }\n if (routePath === \"*\" || routePath === \"/*\") {\n handlers.push([handler, emptyParams]);\n continue;\n }\n const hasStar = routePath.indexOf(\"*\") !== -1;\n const hasLabel = routePath.indexOf(\":\") !== -1;\n if (!hasStar && !hasLabel) {\n if (routePath === path || routePath + \"/\" === path) {\n handlers.push([handler, emptyParams]);\n }\n } else if (hasStar && !hasLabel) {\n const endsWithStar = routePath.charCodeAt(routePath.length - 1) === 42;\n const parts = (endsWithStar ? routePath.slice(0, -2) : routePath).split(splitByStarRe);\n const lastIndex = parts.length - 1;\n for (let j = 0, pos = 0, len2 = parts.length; j < len2; j++) {\n const part = parts[j];\n const index = path.indexOf(part, pos);\n if (index !== pos) {\n continue ROUTES_LOOP;\n }\n pos += part.length;\n if (j === lastIndex) {\n if (!endsWithStar && pos !== path.length && !(pos === path.length - 1 && path.charCodeAt(pos) === 47)) {\n continue ROUTES_LOOP;\n }\n } else {\n const index2 = path.indexOf(\"/\", pos);\n if (index2 === -1) {\n continue ROUTES_LOOP;\n }\n pos = index2;\n }\n }\n handlers.push([handler, emptyParams]);\n } else if (hasLabel && !hasStar) {\n const params = /* @__PURE__ */ Object.create(null);\n const parts = routePath.match(splitPathRe);\n const lastIndex = parts.length - 1;\n for (let j = 0, pos = 0, len2 = parts.length; j < len2; j++) {\n if (pos === -1 || pos >= path.length) {\n continue ROUTES_LOOP;\n }\n const part = parts[j];\n if (part.charCodeAt(1) === 58) {\n let name = part.slice(2);\n let value;\n if (name.charCodeAt(name.length - 1) === 125) {\n const openBracePos = name.indexOf(\"{\");\n const pattern = name.slice(openBracePos + 1, -1);\n const restPath = path.slice(pos + 1);\n const match = new RegExp(pattern, \"d\").exec(restPath);\n if (!match || match.indices[0][0] !== 0 || match.indices[0][1] === 0) {\n continue ROUTES_LOOP;\n }\n name = name.slice(0, openBracePos);\n value = restPath.slice(...match.indices[0]);\n pos += match.indices[0][1] + 1;\n } else {\n let endValuePos = path.indexOf(\"/\", pos + 1);\n if (endValuePos === -1) {\n if (pos + 1 === path.length) {\n continue ROUTES_LOOP;\n }\n endValuePos = path.length;\n }\n value = path.slice(pos + 1, endValuePos);\n pos = endValuePos;\n }\n params[name] ||= value;\n } else {\n const index = path.indexOf(part, pos);\n if (index !== pos) {\n continue ROUTES_LOOP;\n }\n pos += part.length;\n }\n if (j === lastIndex) {\n if (pos !== path.length && !(pos === path.length - 1 && path.charCodeAt(pos) === 47)) {\n continue ROUTES_LOOP;\n }\n }\n }\n handlers.push([handler, params]);\n } else if (hasLabel && hasStar) {\n throw new UnsupportedPathError();\n }\n }\n return [handlers];\n }\n};\nexport {\n LinearRouter\n};\n","// src/router/reg-exp-router/node.ts\nvar LABEL_REG_EXP_STR = \"[^/]+\";\nvar ONLY_WILDCARD_REG_EXP_STR = \".*\";\nvar TAIL_WILDCARD_REG_EXP_STR = \"(?:|/.*)\";\nvar PATH_ERROR = Symbol();\nvar regExpMetaChars = new Set(\".\\\\+*[^]$()\");\nfunction compareKey(a, b) {\n if (a.length === 1) {\n return b.length === 1 ? a < b ? -1 : 1 : -1;\n }\n if (b.length === 1) {\n return 1;\n }\n if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) {\n return 1;\n } else if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) {\n return -1;\n }\n if (a === LABEL_REG_EXP_STR) {\n return 1;\n } else if (b === LABEL_REG_EXP_STR) {\n return -1;\n }\n return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;\n}\nvar Node = class {\n index;\n varIndex;\n children = /* @__PURE__ */ Object.create(null);\n insert(tokens, index, paramMap, context, pathErrorCheckOnly) {\n if (tokens.length === 0) {\n if (this.index !== void 0) {\n throw PATH_ERROR;\n }\n if (pathErrorCheckOnly) {\n return;\n }\n this.index = index;\n return;\n }\n const [token, ...restTokens] = tokens;\n const pattern = token === \"*\" ? restTokens.length === 0 ? [\"\", \"\", ONLY_WILDCARD_REG_EXP_STR] : [\"\", \"\", LABEL_REG_EXP_STR] : token === \"/*\" ? [\"\", \"\", TAIL_WILDCARD_REG_EXP_STR] : token.match(/^\\:([^\\{\\}]+)(?:\\{(.+)\\})?$/);\n let node;\n if (pattern) {\n const name = pattern[1];\n let regexpStr = pattern[2] || LABEL_REG_EXP_STR;\n if (name && pattern[2]) {\n regexpStr = regexpStr.replace(/^\\((?!\\?:)(?=[^)]+\\)$)/, \"(?:\");\n if (/\\((?!\\?:)/.test(regexpStr)) {\n throw PATH_ERROR;\n }\n }\n node = this.children[regexpStr];\n if (!node) {\n if (Object.keys(this.children).some(\n (k) => k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR\n )) {\n throw PATH_ERROR;\n }\n if (pathErrorCheckOnly) {\n return;\n }\n node = this.children[regexpStr] = new Node();\n if (name !== \"\") {\n node.varIndex = context.varIndex++;\n }\n }\n if (!pathErrorCheckOnly && name !== \"\") {\n paramMap.push([name, node.varIndex]);\n }\n } else {\n node = this.children[token];\n if (!node) {\n if (Object.keys(this.children).some(\n (k) => k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR\n )) {\n throw PATH_ERROR;\n }\n if (pathErrorCheckOnly) {\n return;\n }\n node = this.children[token] = new Node();\n }\n }\n node.insert(restTokens, index, paramMap, context, pathErrorCheckOnly);\n }\n buildRegExpStr() {\n const childKeys = Object.keys(this.children).sort(compareKey);\n const strList = childKeys.map((k) => {\n const c = this.children[k];\n return (typeof c.varIndex === \"number\" ? `(${k})@${c.varIndex}` : regExpMetaChars.has(k) ? `\\\\${k}` : k) + c.buildRegExpStr();\n });\n if (typeof this.index === \"number\") {\n strList.unshift(`#${this.index}`);\n }\n if (strList.length === 0) {\n return \"\";\n }\n if (strList.length === 1) {\n return strList[0];\n }\n return \"(?:\" + strList.join(\"|\") + \")\";\n }\n};\nexport {\n Node,\n PATH_ERROR\n};\n","// src/router/reg-exp-router/trie.ts\nimport { Node } from \"./node.js\";\nvar Trie = class {\n context = { varIndex: 0 };\n root = new Node();\n insert(path, index, pathErrorCheckOnly) {\n const paramAssoc = [];\n const groups = [];\n for (let i = 0; ; ) {\n let replaced = false;\n path = path.replace(/\\{[^}]+\\}/g, (m) => {\n const mark = `@\\\\${i}`;\n groups[i] = [mark, m];\n i++;\n replaced = true;\n return mark;\n });\n if (!replaced) {\n break;\n }\n }\n const tokens = path.match(/(?::[^\\/]+)|(?:\\/\\*$)|./g) || [];\n for (let i = groups.length - 1; i >= 0; i--) {\n const [mark] = groups[i];\n for (let j = tokens.length - 1; j >= 0; j--) {\n if (tokens[j].indexOf(mark) !== -1) {\n tokens[j] = tokens[j].replace(mark, groups[i][1]);\n break;\n }\n }\n }\n this.root.insert(tokens, index, paramAssoc, this.context, pathErrorCheckOnly);\n return paramAssoc;\n }\n buildRegExp() {\n let regexp = this.root.buildRegExpStr();\n if (regexp === \"\") {\n return [/^$/, [], []];\n }\n let captureIndex = 0;\n const indexReplacementMap = [];\n const paramReplacementMap = [];\n regexp = regexp.replace(/#(\\d+)|@(\\d+)|\\.\\*\\$/g, (_, handlerIndex, paramIndex) => {\n if (typeof handlerIndex !== \"undefined\") {\n indexReplacementMap[++captureIndex] = Number(handlerIndex);\n return \"$()\";\n }\n if (typeof paramIndex !== \"undefined\") {\n paramReplacementMap[Number(paramIndex)] = ++captureIndex;\n return \"\";\n }\n return \"\";\n });\n return [new RegExp(`^${regexp}`), indexReplacementMap, paramReplacementMap];\n }\n};\nexport {\n Trie\n};\n","// src/router/reg-exp-router/router.ts\nimport {\n MESSAGE_MATCHER_IS_ALREADY_BUILT,\n METHOD_NAME_ALL,\n UnsupportedPathError\n} from \"../../router.js\";\nimport { checkOptionalParameter } from \"../../utils/url.js\";\nimport { PATH_ERROR } from \"./node.js\";\nimport { Trie } from \"./trie.js\";\nvar emptyParam = [];\nvar nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];\nvar wildcardRegExpCache = /* @__PURE__ */ Object.create(null);\nfunction buildWildcardRegExp(path) {\n return wildcardRegExpCache[path] ??= new RegExp(\n path === \"*\" ? \"\" : `^${path.replace(\n /\\/\\*$|([.\\\\+*[^\\]$()])/g,\n (_, metaChar) => metaChar ? `\\\\${metaChar}` : \"(?:|/.*)\"\n )}$`\n );\n}\nfunction clearWildcardRegExpCache() {\n wildcardRegExpCache = /* @__PURE__ */ Object.create(null);\n}\nfunction buildMatcherFromPreprocessedRoutes(routes) {\n const trie = new Trie();\n const handlerData = [];\n if (routes.length === 0) {\n return nullMatcher;\n }\n const routesWithStaticPathFlag = routes.map(\n (route) => [!/\\*|\\/:/.test(route[0]), ...route]\n ).sort(\n ([isStaticA, pathA], [isStaticB, pathB]) => isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length\n );\n const staticMap = /* @__PURE__ */ Object.create(null);\n for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {\n const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];\n if (pathErrorCheckOnly) {\n staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];\n } else {\n j++;\n }\n let paramAssoc;\n try {\n paramAssoc = trie.insert(path, j, pathErrorCheckOnly);\n } catch (e) {\n throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;\n }\n if (pathErrorCheckOnly) {\n continue;\n }\n handlerData[j] = handlers.map(([h, paramCount]) => {\n const paramIndexMap = /* @__PURE__ */ Object.create(null);\n paramCount -= 1;\n for (; paramCount >= 0; paramCount--) {\n const [key, value] = paramAssoc[paramCount];\n paramIndexMap[key] = value;\n }\n return [h, paramIndexMap];\n });\n }\n const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();\n for (let i = 0, len = handlerData.length; i < len; i++) {\n for (let j = 0, len2 = handlerData[i].length; j < len2; j++) {\n const map = handlerData[i][j]?.[1];\n if (!map) {\n continue;\n }\n const keys = Object.keys(map);\n for (let k = 0, len3 = keys.length; k < len3; k++) {\n map[keys[k]] = paramReplacementMap[map[keys[k]]];\n }\n }\n }\n const handlerMap = [];\n for (const i in indexReplacementMap) {\n handlerMap[i] = handlerData[indexReplacementMap[i]];\n }\n return [regexp, handlerMap, staticMap];\n}\nfunction findMiddleware(middleware, path) {\n if (!middleware) {\n return void 0;\n }\n for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {\n if (buildWildcardRegExp(k).test(path)) {\n return [...middleware[k]];\n }\n }\n return void 0;\n}\nvar RegExpRouter = class {\n name = \"RegExpRouter\";\n middleware;\n routes;\n constructor() {\n this.middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };\n this.routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };\n }\n add(method, path, handler) {\n const { middleware, routes } = this;\n if (!middleware || !routes) {\n throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);\n }\n if (!middleware[method]) {\n ;\n [middleware, routes].forEach((handlerMap) => {\n handlerMap[method] = /* @__PURE__ */ Object.create(null);\n Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p) => {\n handlerMap[method][p] = [...handlerMap[METHOD_NAME_ALL][p]];\n });\n });\n }\n if (path === \"/*\") {\n path = \"*\";\n }\n const paramCount = (path.match(/\\/:/g) || []).length;\n if (/\\*$/.test(path)) {\n const re = buildWildcardRegExp(path);\n if (method === METHOD_NAME_ALL) {\n Object.keys(middleware).forEach((m) => {\n middleware[m][path] ||= findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];\n });\n } else {\n middleware[method][path] ||= findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];\n }\n Object.keys(middleware).forEach((m) => {\n if (method === METHOD_NAME_ALL || method === m) {\n Object.keys(middleware[m]).forEach((p) => {\n re.test(p) && middleware[m][p].push([handler, paramCount]);\n });\n }\n });\n Object.keys(routes).forEach((m) => {\n if (method === METHOD_NAME_ALL || method === m) {\n Object.keys(routes[m]).forEach(\n (p) => re.test(p) && routes[m][p].push([handler, paramCount])\n );\n }\n });\n return;\n }\n const paths = checkOptionalParameter(path) || [path];\n for (let i = 0, len = paths.length; i < len; i++) {\n const path2 = paths[i];\n Object.keys(routes).forEach((m) => {\n if (method === METHOD_NAME_ALL || method === m) {\n routes[m][path2] ||= [\n ...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []\n ];\n routes[m][path2].push([handler, paramCount - len + i + 1]);\n }\n });\n }\n }\n match(method, path) {\n clearWildcardRegExpCache();\n const matchers = this.buildAllMatchers();\n this.match = (method2, path2) => {\n const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];\n const staticMatch = matcher[2][path2];\n if (staticMatch) {\n return staticMatch;\n }\n const match = path2.match(matcher[0]);\n if (!match) {\n return [[], emptyParam];\n }\n const index = match.indexOf(\"\", 1);\n return [matcher[1][index], match];\n };\n return this.match(method, path);\n }\n buildAllMatchers() {\n const matchers = /* @__PURE__ */ Object.create(null);\n [...Object.keys(this.routes), ...Object.keys(this.middleware)].forEach((method) => {\n matchers[method] ||= this.buildMatcher(method);\n });\n this.middleware = this.routes = void 0;\n return matchers;\n }\n buildMatcher(method) {\n const routes = [];\n let hasOwnRoute = method === METHOD_NAME_ALL;\n [this.middleware, this.routes].forEach((r) => {\n const ownRoute = r[method] ? Object.keys(r[method]).map((path) => [path, r[method][path]]) : [];\n if (ownRoute.length !== 0) {\n hasOwnRoute ||= true;\n routes.push(...ownRoute);\n } else if (method !== METHOD_NAME_ALL) {\n routes.push(\n ...Object.keys(r[METHOD_NAME_ALL]).map((path) => [path, r[METHOD_NAME_ALL][path]])\n );\n }\n });\n if (!hasOwnRoute) {\n return null;\n } else {\n return buildMatcherFromPreprocessedRoutes(routes);\n }\n }\n};\nexport {\n RegExpRouter\n};\n"],"mappings":";;;;;;;AAEA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACnBP,IAAI,kBAAkB;AAGtB,IAAI,mCAAmC;AACvC,IAAI,uBAAuB,cAAc,MAAM;AAC/C;;;ACyGA,IAAI,yBAAyB,CAAC,SAAS;AACrC,MAAI,CAAC,KAAK,MAAM,SAAS,GAAG;AAC1B,WAAO;AAAA,EACT;AACA,QAAM,WAAW,KAAK,MAAM,GAAG;AAC/B,QAAM,UAAU,CAAC;AACjB,MAAI,WAAW;AACf,W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MAAM,QAAQ,IAAI,WAAW,UAAU,MAAM;AAErD,eAAO,IAAI,SAAS,MAAM;AAAA,UACxB,QAAQ;AAAA,UACR;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAAA,IACH,SAAS,GAAG;AACV,YAAM,QACJ,aAAa,YACT,IACA,IAAI,UAAU;AAAA,QACZ,MAAM;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,MACT,CAAC;AAEP,YAAM,EAAE,MAAM,QAAQ,IAAI,WAAW,UAAU,MAAM,OAAO,CAAC;AAE7D,aAAO,IAAI,SAAS,MAAM;AAAA,QACxB,QAAQ,MAAM;AAAA,QACd;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,SAAS,wBAAwB,MAAwB;AACvD,SAAO,oBAAoB,IAAI,EAAE,QAAQ,gBAAgB,KAAK;AAChE;","names":[]}
|
package/dist/index.js
ADDED
@@ -0,0 +1,403 @@
|
|
1
|
+
import {
|
2
|
+
Procedure,
|
3
|
+
createProcedureCaller,
|
4
|
+
decorateMiddleware,
|
5
|
+
decorateProcedure,
|
6
|
+
hook,
|
7
|
+
isProcedure,
|
8
|
+
mergeContext
|
9
|
+
} from "./chunk-ACLC6USM.js";
|
10
|
+
|
11
|
+
// src/builder.ts
|
12
|
+
import {
|
13
|
+
ContractProcedure,
|
14
|
+
isContractProcedure as isContractProcedure2
|
15
|
+
} from "@orpc/contract";
|
16
|
+
|
17
|
+
// src/procedure-builder.ts
|
18
|
+
import {
|
19
|
+
DecoratedContractProcedure
|
20
|
+
} from "@orpc/contract";
|
21
|
+
|
22
|
+
// src/procedure-implementer.ts
|
23
|
+
var ProcedureImplementer = class _ProcedureImplementer {
|
24
|
+
constructor(zz$pi) {
|
25
|
+
this.zz$pi = zz$pi;
|
26
|
+
}
|
27
|
+
use(middleware, mapInput) {
|
28
|
+
const middleware_ = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
29
|
+
return new _ProcedureImplementer({
|
30
|
+
...this.zz$pi,
|
31
|
+
middlewares: [...this.zz$pi.middlewares ?? [], middleware_]
|
32
|
+
});
|
33
|
+
}
|
34
|
+
handler(handler) {
|
35
|
+
return decorateProcedure({
|
36
|
+
zz$p: {
|
37
|
+
middlewares: this.zz$pi.middlewares,
|
38
|
+
contract: this.zz$pi.contract,
|
39
|
+
handler
|
40
|
+
}
|
41
|
+
});
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
// src/procedure-builder.ts
|
46
|
+
var ProcedureBuilder = class _ProcedureBuilder {
|
47
|
+
constructor(zz$pb) {
|
48
|
+
this.zz$pb = zz$pb;
|
49
|
+
}
|
50
|
+
/**
|
51
|
+
* Self chainable
|
52
|
+
*/
|
53
|
+
route(opts) {
|
54
|
+
return new _ProcedureBuilder({
|
55
|
+
...this.zz$pb,
|
56
|
+
contract: DecoratedContractProcedure.decorate(this.zz$pb.contract).route(
|
57
|
+
opts
|
58
|
+
)
|
59
|
+
});
|
60
|
+
}
|
61
|
+
input(schema, example) {
|
62
|
+
return new _ProcedureBuilder({
|
63
|
+
...this.zz$pb,
|
64
|
+
contract: DecoratedContractProcedure.decorate(this.zz$pb.contract).input(
|
65
|
+
schema,
|
66
|
+
example
|
67
|
+
)
|
68
|
+
});
|
69
|
+
}
|
70
|
+
output(schema, example) {
|
71
|
+
return new _ProcedureBuilder({
|
72
|
+
...this.zz$pb,
|
73
|
+
contract: DecoratedContractProcedure.decorate(this.zz$pb.contract).output(
|
74
|
+
schema,
|
75
|
+
example
|
76
|
+
)
|
77
|
+
});
|
78
|
+
}
|
79
|
+
use(middleware, mapInput) {
|
80
|
+
if (!mapInput) {
|
81
|
+
return new ProcedureImplementer({
|
82
|
+
contract: this.zz$pb.contract,
|
83
|
+
middlewares: this.zz$pb.middlewares
|
84
|
+
}).use(middleware);
|
85
|
+
}
|
86
|
+
return new ProcedureImplementer({
|
87
|
+
contract: this.zz$pb.contract,
|
88
|
+
middlewares: this.zz$pb.middlewares
|
89
|
+
}).use(middleware, mapInput);
|
90
|
+
}
|
91
|
+
/**
|
92
|
+
* Convert to Procedure
|
93
|
+
*/
|
94
|
+
handler(handler) {
|
95
|
+
return decorateProcedure({
|
96
|
+
zz$p: {
|
97
|
+
middlewares: this.zz$pb.middlewares,
|
98
|
+
contract: this.zz$pb.contract,
|
99
|
+
handler
|
100
|
+
}
|
101
|
+
});
|
102
|
+
}
|
103
|
+
};
|
104
|
+
|
105
|
+
// src/router-builder.ts
|
106
|
+
import { DecoratedContractProcedure as DecoratedContractProcedure2 } from "@orpc/contract";
|
107
|
+
var RouterBuilder = class _RouterBuilder {
|
108
|
+
constructor(zz$rb) {
|
109
|
+
this.zz$rb = zz$rb;
|
110
|
+
}
|
111
|
+
prefix(prefix) {
|
112
|
+
return new _RouterBuilder({
|
113
|
+
...this.zz$rb,
|
114
|
+
prefix: `${this.zz$rb.prefix ?? ""}${prefix}`
|
115
|
+
});
|
116
|
+
}
|
117
|
+
tags(...tags) {
|
118
|
+
if (!tags.length) return this;
|
119
|
+
return new _RouterBuilder({
|
120
|
+
...this.zz$rb,
|
121
|
+
tags: [...this.zz$rb.tags ?? [], ...tags]
|
122
|
+
});
|
123
|
+
}
|
124
|
+
use(middleware, mapInput) {
|
125
|
+
const middleware_ = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
126
|
+
return new _RouterBuilder({
|
127
|
+
...this.zz$rb,
|
128
|
+
middlewares: [...this.zz$rb.middlewares || [], middleware_]
|
129
|
+
});
|
130
|
+
}
|
131
|
+
router(router) {
|
132
|
+
const handled = {};
|
133
|
+
for (const key in router) {
|
134
|
+
const item = router[key];
|
135
|
+
if (isProcedure(item)) {
|
136
|
+
const builderMiddlewares = this.zz$rb.middlewares ?? [];
|
137
|
+
const itemMiddlewares = item.zz$p.middlewares ?? [];
|
138
|
+
const middlewares = [
|
139
|
+
...builderMiddlewares,
|
140
|
+
...itemMiddlewares.filter(
|
141
|
+
(item2) => !builderMiddlewares.includes(item2)
|
142
|
+
)
|
143
|
+
];
|
144
|
+
const contract = DecoratedContractProcedure2.decorate(
|
145
|
+
item.zz$p.contract
|
146
|
+
).addTags(...this.zz$rb.tags ?? []);
|
147
|
+
handled[key] = decorateProcedure({
|
148
|
+
zz$p: {
|
149
|
+
...item.zz$p,
|
150
|
+
contract: this.zz$rb.prefix ? contract.prefix(this.zz$rb.prefix) : contract,
|
151
|
+
middlewares
|
152
|
+
}
|
153
|
+
});
|
154
|
+
} else {
|
155
|
+
handled[key] = this.router(item);
|
156
|
+
}
|
157
|
+
}
|
158
|
+
return handled;
|
159
|
+
}
|
160
|
+
};
|
161
|
+
|
162
|
+
// src/router-implementer.ts
|
163
|
+
import {
|
164
|
+
isContractProcedure
|
165
|
+
} from "@orpc/contract";
|
166
|
+
var RouterImplementer = class {
|
167
|
+
constructor(zz$ri) {
|
168
|
+
this.zz$ri = zz$ri;
|
169
|
+
}
|
170
|
+
router(router) {
|
171
|
+
assertRouterImplementation(this.zz$ri.contract, router);
|
172
|
+
return router;
|
173
|
+
}
|
174
|
+
};
|
175
|
+
function chainRouterImplementer(contract, middlewares) {
|
176
|
+
const result = {};
|
177
|
+
for (const key in contract) {
|
178
|
+
const item = contract[key];
|
179
|
+
if (isContractProcedure(item)) {
|
180
|
+
result[key] = new ProcedureImplementer({
|
181
|
+
contract: item,
|
182
|
+
middlewares
|
183
|
+
});
|
184
|
+
} else {
|
185
|
+
result[key] = chainRouterImplementer(item, middlewares);
|
186
|
+
}
|
187
|
+
}
|
188
|
+
const implementer = new RouterImplementer({ contract });
|
189
|
+
return Object.assign(implementer, result);
|
190
|
+
}
|
191
|
+
function assertRouterImplementation(contract, router, path = []) {
|
192
|
+
for (const key in contract) {
|
193
|
+
const currentPath = [...path, key];
|
194
|
+
const contractItem = contract[key];
|
195
|
+
const routerItem = router[key];
|
196
|
+
if (!routerItem) {
|
197
|
+
throw new Error(
|
198
|
+
`Missing implementation for procedure at [${currentPath.join(".")}]`
|
199
|
+
);
|
200
|
+
}
|
201
|
+
if (isContractProcedure(contractItem)) {
|
202
|
+
if (isProcedure(routerItem)) {
|
203
|
+
if (routerItem.zz$p.contract !== contractItem) {
|
204
|
+
throw new Error(
|
205
|
+
`Mismatch implementation for procedure at [${currentPath.join(".")}]`
|
206
|
+
);
|
207
|
+
}
|
208
|
+
} else {
|
209
|
+
throw new Error(
|
210
|
+
`Mismatch implementation for procedure at [${currentPath.join(".")}]`
|
211
|
+
);
|
212
|
+
}
|
213
|
+
} else {
|
214
|
+
assertRouterImplementation(
|
215
|
+
contractItem,
|
216
|
+
routerItem,
|
217
|
+
currentPath
|
218
|
+
);
|
219
|
+
}
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
// src/builder.ts
|
224
|
+
var Builder = class _Builder {
|
225
|
+
constructor(zz$b = {}) {
|
226
|
+
this.zz$b = zz$b;
|
227
|
+
}
|
228
|
+
/**
|
229
|
+
* Self chainable
|
230
|
+
*/
|
231
|
+
context() {
|
232
|
+
return this;
|
233
|
+
}
|
234
|
+
use(middleware, mapInput) {
|
235
|
+
const middleware_ = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
236
|
+
return new _Builder({
|
237
|
+
...this.zz$b,
|
238
|
+
middlewares: [...this.zz$b.middlewares || [], middleware_]
|
239
|
+
});
|
240
|
+
}
|
241
|
+
/**
|
242
|
+
* Convert to ContractProcedureBuilder
|
243
|
+
*/
|
244
|
+
route(opts) {
|
245
|
+
return new ProcedureBuilder({
|
246
|
+
middlewares: this.zz$b.middlewares,
|
247
|
+
contract: new ContractProcedure({
|
248
|
+
...opts,
|
249
|
+
InputSchema: void 0,
|
250
|
+
OutputSchema: void 0
|
251
|
+
})
|
252
|
+
});
|
253
|
+
}
|
254
|
+
input(schema, example) {
|
255
|
+
return new ProcedureBuilder({
|
256
|
+
middlewares: this.zz$b.middlewares,
|
257
|
+
contract: new ContractProcedure({
|
258
|
+
OutputSchema: void 0,
|
259
|
+
InputSchema: schema,
|
260
|
+
inputExample: example
|
261
|
+
})
|
262
|
+
});
|
263
|
+
}
|
264
|
+
output(schema, example) {
|
265
|
+
return new ProcedureBuilder({
|
266
|
+
middlewares: this.zz$b.middlewares,
|
267
|
+
contract: new ContractProcedure({
|
268
|
+
InputSchema: void 0,
|
269
|
+
OutputSchema: schema,
|
270
|
+
outputExample: example
|
271
|
+
})
|
272
|
+
});
|
273
|
+
}
|
274
|
+
/**
|
275
|
+
* Convert to Procedure
|
276
|
+
*/
|
277
|
+
handler(handler) {
|
278
|
+
return decorateProcedure({
|
279
|
+
zz$p: {
|
280
|
+
middlewares: this.zz$b.middlewares,
|
281
|
+
contract: new ContractProcedure({
|
282
|
+
InputSchema: void 0,
|
283
|
+
OutputSchema: void 0
|
284
|
+
}),
|
285
|
+
handler
|
286
|
+
}
|
287
|
+
});
|
288
|
+
}
|
289
|
+
/**
|
290
|
+
* Convert to ProcedureImplementer | RouterBuilder
|
291
|
+
*/
|
292
|
+
contract(contract) {
|
293
|
+
if (isContractProcedure2(contract)) {
|
294
|
+
return new ProcedureImplementer({
|
295
|
+
contract,
|
296
|
+
middlewares: this.zz$b.middlewares
|
297
|
+
});
|
298
|
+
}
|
299
|
+
return chainRouterImplementer(
|
300
|
+
contract,
|
301
|
+
this.zz$b.middlewares
|
302
|
+
);
|
303
|
+
}
|
304
|
+
/**
|
305
|
+
* Create ExtendedMiddleware
|
306
|
+
*/
|
307
|
+
middleware(middleware) {
|
308
|
+
return decorateMiddleware(middleware);
|
309
|
+
}
|
310
|
+
prefix(prefix) {
|
311
|
+
return new RouterBuilder({
|
312
|
+
...this.zz$b,
|
313
|
+
prefix
|
314
|
+
});
|
315
|
+
}
|
316
|
+
tags(...tags) {
|
317
|
+
return new RouterBuilder({
|
318
|
+
...this.zz$b,
|
319
|
+
tags
|
320
|
+
});
|
321
|
+
}
|
322
|
+
/**
|
323
|
+
* Create DecoratedRouter
|
324
|
+
*/
|
325
|
+
router(router) {
|
326
|
+
return new RouterBuilder(this.zz$b).router(router);
|
327
|
+
}
|
328
|
+
};
|
329
|
+
|
330
|
+
// src/index.ts
|
331
|
+
export * from "@orpc/shared/error";
|
332
|
+
|
333
|
+
// src/router.ts
|
334
|
+
import {
|
335
|
+
isContractProcedure as isContractProcedure3
|
336
|
+
} from "@orpc/contract";
|
337
|
+
function toContractRouter(router) {
|
338
|
+
const contract = {};
|
339
|
+
for (const key in router) {
|
340
|
+
const item = router[key];
|
341
|
+
if (isContractProcedure3(item)) {
|
342
|
+
contract[key] = item;
|
343
|
+
} else if (isProcedure(item)) {
|
344
|
+
contract[key] = item.zz$p.contract;
|
345
|
+
} else {
|
346
|
+
contract[key] = toContractRouter(item);
|
347
|
+
}
|
348
|
+
}
|
349
|
+
return contract;
|
350
|
+
}
|
351
|
+
|
352
|
+
// src/router-caller.ts
|
353
|
+
function createRouterCaller(options) {
|
354
|
+
const internal = options.internal ?? true;
|
355
|
+
const validate = options.validate ?? true;
|
356
|
+
const caller = {};
|
357
|
+
for (const key in options.router) {
|
358
|
+
const path = [...options.basePath ?? [], key];
|
359
|
+
const item = options.router[key];
|
360
|
+
if (isProcedure(item)) {
|
361
|
+
caller[key] = createProcedureCaller({
|
362
|
+
procedure: item,
|
363
|
+
context: options.context,
|
364
|
+
hooks: options.hooks,
|
365
|
+
path,
|
366
|
+
internal,
|
367
|
+
validate
|
368
|
+
});
|
369
|
+
} else {
|
370
|
+
caller[key] = createRouterCaller({
|
371
|
+
router: item,
|
372
|
+
context: options.context,
|
373
|
+
hooks: options.hooks,
|
374
|
+
basePath: path,
|
375
|
+
internal,
|
376
|
+
validate
|
377
|
+
});
|
378
|
+
}
|
379
|
+
}
|
380
|
+
return caller;
|
381
|
+
}
|
382
|
+
|
383
|
+
// src/index.ts
|
384
|
+
var os = new Builder();
|
385
|
+
export {
|
386
|
+
Builder,
|
387
|
+
Procedure,
|
388
|
+
ProcedureBuilder,
|
389
|
+
ProcedureImplementer,
|
390
|
+
RouterImplementer,
|
391
|
+
assertRouterImplementation,
|
392
|
+
chainRouterImplementer,
|
393
|
+
createProcedureCaller,
|
394
|
+
createRouterCaller,
|
395
|
+
decorateMiddleware,
|
396
|
+
decorateProcedure,
|
397
|
+
hook,
|
398
|
+
isProcedure,
|
399
|
+
mergeContext,
|
400
|
+
os,
|
401
|
+
toContractRouter
|
402
|
+
};
|
403
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/builder.ts","../src/procedure-builder.ts","../src/procedure-implementer.ts","../src/router-builder.ts","../src/router-implementer.ts","../src/index.ts","../src/router.ts","../src/router-caller.ts"],"sourcesContent":["import {\n ContractProcedure,\n type ContractRouter,\n type HTTPPath,\n type RouteOptions,\n type Schema,\n type SchemaInput,\n type SchemaOutput,\n isContractProcedure,\n} from '@orpc/contract'\nimport type { IsEqual } from '@orpc/shared'\nimport {\n type DecoratedMiddleware,\n type MapInputMiddleware,\n type Middleware,\n decorateMiddleware,\n} from './middleware'\nimport {\n type DecoratedProcedure,\n type ProcedureHandler,\n decorateProcedure,\n} from './procedure'\nimport { ProcedureBuilder } from './procedure-builder'\nimport { ProcedureImplementer } from './procedure-implementer'\nimport type { HandledRouter, Router } from './router'\nimport { RouterBuilder } from './router-builder'\nimport {\n type ChainedRouterImplementer,\n chainRouterImplementer,\n} from './router-implementer'\nimport type { Context, MergeContext } from './types'\n\nexport class Builder<TContext extends Context, TExtraContext extends Context> {\n constructor(\n public zz$b: {\n middlewares?: Middleware<any, any, any, any>[]\n } = {},\n ) {}\n\n /**\n * Self chainable\n */\n\n context<UContext extends Context>(): IsEqual<UContext, Context> extends true\n ? Builder<TContext, TExtraContext>\n : Builder<UContext, TExtraContext> {\n return this as any\n }\n\n use<\n UExtraContext extends\n | Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>>\n | undefined = undefined,\n >(\n middleware: Middleware<\n MergeContext<TContext, TExtraContext>,\n UExtraContext,\n unknown,\n unknown\n >,\n ): Builder<TContext, MergeContext<TExtraContext, UExtraContext>>\n\n use<\n UExtraContext extends\n | Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>>\n | undefined = undefined,\n UMappedInput = unknown,\n >(\n middleware: Middleware<\n MergeContext<TContext, TExtraContext>,\n UExtraContext,\n UMappedInput,\n unknown\n >,\n mapInput: MapInputMiddleware<unknown, UMappedInput>,\n ): Builder<TContext, MergeContext<TExtraContext, UExtraContext>>\n\n use(\n middleware: Middleware<any, any, any, any>,\n mapInput?: MapInputMiddleware<any, any>,\n ): Builder<any, any> {\n const middleware_ = mapInput\n ? decorateMiddleware(middleware).mapInput(mapInput)\n : middleware\n\n return new Builder({\n ...this.zz$b,\n middlewares: [...(this.zz$b.middlewares || []), middleware_],\n })\n }\n\n /**\n * Convert to ContractProcedureBuilder\n */\n\n route(\n opts: RouteOptions,\n ): ProcedureBuilder<TContext, TExtraContext, undefined, undefined> {\n return new ProcedureBuilder({\n middlewares: this.zz$b.middlewares,\n contract: new ContractProcedure({\n ...opts,\n InputSchema: undefined,\n OutputSchema: undefined,\n }),\n })\n }\n\n input<USchema extends Schema = undefined>(\n schema: USchema,\n example?: SchemaInput<USchema>,\n ): ProcedureBuilder<TContext, TExtraContext, USchema, undefined> {\n return new ProcedureBuilder({\n middlewares: this.zz$b.middlewares,\n contract: new ContractProcedure({\n OutputSchema: undefined,\n InputSchema: schema,\n inputExample: example,\n }),\n })\n }\n\n output<USchema extends Schema = undefined>(\n schema: USchema,\n example?: SchemaOutput<USchema>,\n ): ProcedureBuilder<TContext, TExtraContext, undefined, USchema> {\n return new ProcedureBuilder({\n middlewares: this.zz$b.middlewares,\n contract: new ContractProcedure({\n InputSchema: undefined,\n OutputSchema: schema,\n outputExample: example,\n }),\n })\n }\n\n /**\n * Convert to Procedure\n */\n handler<UHandlerOutput = undefined>(\n handler: ProcedureHandler<\n TContext,\n TExtraContext,\n undefined,\n undefined,\n UHandlerOutput\n >,\n ): DecoratedProcedure<\n TContext,\n TExtraContext,\n undefined,\n undefined,\n UHandlerOutput\n > {\n return decorateProcedure({\n zz$p: {\n middlewares: this.zz$b.middlewares,\n contract: new ContractProcedure({\n InputSchema: undefined,\n OutputSchema: undefined,\n }),\n handler,\n },\n })\n }\n\n /**\n * Convert to ProcedureImplementer | RouterBuilder\n */\n\n contract<UContract extends ContractProcedure<any, any> | ContractRouter>(\n contract: UContract,\n ): UContract extends ContractProcedure<\n infer UInputSchema,\n infer UOutputSchema\n >\n ? ProcedureImplementer<TContext, TExtraContext, UInputSchema, UOutputSchema>\n : UContract extends ContractRouter\n ? ChainedRouterImplementer<TContext, UContract, TExtraContext>\n : never {\n if (isContractProcedure(contract)) {\n return new ProcedureImplementer({\n contract,\n middlewares: this.zz$b.middlewares,\n }) as any\n }\n\n return chainRouterImplementer(\n contract as ContractRouter,\n this.zz$b.middlewares,\n ) as any\n }\n\n /**\n * Create ExtendedMiddleware\n */\n\n middleware<UExtraContext extends Context = undefined, TInput = unknown>(\n middleware: Middleware<\n MergeContext<TContext, TExtraContext>,\n UExtraContext,\n TInput,\n unknown\n >,\n ): DecoratedMiddleware<\n MergeContext<TContext, TExtraContext>,\n UExtraContext,\n TInput,\n unknown\n > {\n return decorateMiddleware(middleware)\n }\n\n prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext> {\n return new RouterBuilder({\n ...this.zz$b,\n prefix,\n })\n }\n\n tags(...tags: string[]): RouterBuilder<TContext, TExtraContext> {\n return new RouterBuilder({\n ...this.zz$b,\n tags,\n })\n }\n\n /**\n * Create DecoratedRouter\n */\n router<URouter extends Router<TContext>>(\n router: URouter,\n ): HandledRouter<URouter> {\n return new RouterBuilder<TContext, TExtraContext>(this.zz$b).router(router)\n }\n}\n","import {\n type ContractProcedure,\n DecoratedContractProcedure,\n type RouteOptions,\n type Schema,\n type SchemaInput,\n type SchemaOutput,\n} from '@orpc/contract'\nimport type { MapInputMiddleware, Middleware } from './middleware'\nimport {\n type DecoratedProcedure,\n type ProcedureHandler,\n decorateProcedure,\n} from './procedure'\nimport { ProcedureImplementer } from './procedure-implementer'\nimport type { Context, MergeContext } from './types'\n\nexport class ProcedureBuilder<\n TContext extends Context,\n TExtraContext extends Context,\n TInputSchema extends Schema,\n TOutputSchema extends Schema,\n> {\n constructor(\n public zz$pb: {\n contract: ContractProcedure<TInputSchema, TOutputSchema>\n middlewares?: Middleware<any, any, any, any>[]\n },\n ) {}\n\n /**\n * Self chainable\n */\n\n route(\n opts: RouteOptions,\n ): ProcedureBuilder<TContext, TExtraContext, TInputSchema, TOutputSchema> {\n return new ProcedureBuilder({\n ...this.zz$pb,\n contract: DecoratedContractProcedure.decorate(this.zz$pb.contract).route(\n opts,\n ),\n })\n }\n\n input<USchema extends Schema = undefined>(\n schema: USchema,\n example?: SchemaInput<USchema>,\n ): ProcedureBuilder<TContext, TExtraContext, USchema, TOutputSchema> {\n return new ProcedureBuilder({\n ...this.zz$pb,\n contract: DecoratedContractProcedure.decorate(this.zz$pb.contract).input(\n schema,\n example,\n ),\n })\n }\n\n output<USchema extends Schema = undefined>(\n schema: USchema,\n example?: SchemaOutput<USchema>,\n ): ProcedureBuilder<TContext, TExtraContext, TInputSchema, USchema> {\n return new ProcedureBuilder({\n ...this.zz$pb,\n contract: DecoratedContractProcedure.decorate(this.zz$pb.contract).output(\n schema,\n example,\n ),\n })\n }\n\n /**\n * Convert to ProcedureBuilder\n */\n\n use<\n UExtraContext extends\n | Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>>\n | undefined = undefined,\n >(\n middleware: Middleware<\n MergeContext<TContext, TExtraContext>,\n UExtraContext,\n SchemaOutput<TInputSchema>,\n SchemaOutput<TOutputSchema>\n >,\n ): ProcedureImplementer<\n TContext,\n MergeContext<TExtraContext, UExtraContext>,\n TInputSchema,\n TOutputSchema\n >\n\n use<\n UExtraContext extends\n | Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>>\n | undefined = undefined,\n UMappedInput = unknown,\n >(\n middleware: Middleware<\n MergeContext<TContext, TExtraContext>,\n UExtraContext,\n UMappedInput,\n SchemaOutput<TOutputSchema>\n >,\n mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UMappedInput>,\n ): ProcedureImplementer<\n TContext,\n MergeContext<TExtraContext, UExtraContext>,\n TInputSchema,\n TOutputSchema\n >\n\n use(\n middleware: Middleware<any, any, any, any>,\n mapInput?: MapInputMiddleware<any, any>,\n ): ProcedureImplementer<any, any, any, any> {\n if (!mapInput) {\n return new ProcedureImplementer({\n contract: this.zz$pb.contract,\n middlewares: this.zz$pb.middlewares,\n }).use(middleware)\n }\n\n return new ProcedureImplementer({\n contract: this.zz$pb.contract,\n middlewares: this.zz$pb.middlewares,\n }).use(middleware, mapInput)\n }\n\n /**\n * Convert to Procedure\n */\n\n handler<UHandlerOutput extends SchemaOutput<TOutputSchema>>(\n handler: ProcedureHandler<\n TContext,\n TExtraContext,\n TInputSchema,\n TOutputSchema,\n UHandlerOutput\n >,\n ): DecoratedProcedure<\n TContext,\n TExtraContext,\n TInputSchema,\n TOutputSchema,\n UHandlerOutput\n > {\n return decorateProcedure({\n zz$p: {\n middlewares: this.zz$pb.middlewares,\n contract: this.zz$pb.contract,\n handler,\n },\n })\n }\n}\n","import type { ContractProcedure, SchemaOutput } from '@orpc/contract'\nimport type { Schema } from '@orpc/contract'\nimport {\n type MapInputMiddleware,\n type Middleware,\n decorateMiddleware,\n} from './middleware'\nimport {\n type DecoratedProcedure,\n type ProcedureHandler,\n decorateProcedure,\n} from './procedure'\nimport type { Context, MergeContext } from './types'\n\nexport class ProcedureImplementer<\n TContext extends Context,\n TExtraContext extends Context,\n TInputSchema extends Schema,\n TOutputSchema extends Schema,\n> {\n constructor(\n public zz$pi: {\n contract: ContractProcedure<TInputSchema, TOutputSchema>\n middlewares?: Middleware<any, any, any, any>[]\n },\n ) {}\n\n use<\n UExtraContext extends\n | Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>>\n | undefined = undefined,\n >(\n middleware: Middleware<\n MergeContext<TContext, TExtraContext>,\n UExtraContext,\n SchemaOutput<TInputSchema>,\n SchemaOutput<TOutputSchema>\n >,\n ): ProcedureImplementer<\n TContext,\n MergeContext<TExtraContext, UExtraContext>,\n TInputSchema,\n TOutputSchema\n >\n\n use<\n UExtraContext extends\n | Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>>\n | undefined = undefined,\n UMappedInput = unknown,\n >(\n middleware: Middleware<\n MergeContext<TContext, TExtraContext>,\n UExtraContext,\n UMappedInput,\n SchemaOutput<TOutputSchema>\n >,\n mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UMappedInput>,\n ): ProcedureImplementer<\n TContext,\n MergeContext<TExtraContext, UExtraContext>,\n TInputSchema,\n TOutputSchema\n >\n\n use(\n middleware: Middleware<any, any, any, any>,\n mapInput?: MapInputMiddleware<any, any>,\n ): ProcedureImplementer<any, any, any, any> {\n const middleware_ = mapInput\n ? decorateMiddleware(middleware).mapInput(mapInput)\n : middleware\n\n return new ProcedureImplementer({\n ...this.zz$pi,\n middlewares: [...(this.zz$pi.middlewares ?? []), middleware_],\n })\n }\n\n handler<UHandlerOutput extends SchemaOutput<TOutputSchema>>(\n handler: ProcedureHandler<\n TContext,\n TExtraContext,\n TInputSchema,\n TOutputSchema,\n UHandlerOutput\n >,\n ): DecoratedProcedure<\n TContext,\n TExtraContext,\n TInputSchema,\n TOutputSchema,\n UHandlerOutput\n > {\n return decorateProcedure({\n zz$p: {\n middlewares: this.zz$pi.middlewares,\n contract: this.zz$pi.contract,\n handler,\n },\n })\n }\n}\n","import { DecoratedContractProcedure, type HTTPPath } from '@orpc/contract'\nimport {\n type MapInputMiddleware,\n type Middleware,\n decorateMiddleware,\n} from './middleware'\nimport { decorateProcedure, isProcedure } from './procedure'\nimport type { HandledRouter, Router } from './router'\nimport type { Context, MergeContext } from './types'\n\nexport class RouterBuilder<\n TContext extends Context,\n TExtraContext extends Context,\n> {\n constructor(\n public zz$rb: {\n prefix?: HTTPPath\n tags?: string[]\n middlewares?: Middleware<any, any, any, any>[]\n },\n ) {}\n\n prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext> {\n return new RouterBuilder({\n ...this.zz$rb,\n prefix: `${this.zz$rb.prefix ?? ''}${prefix}`,\n })\n }\n\n tags(...tags: string[]): RouterBuilder<TContext, TExtraContext> {\n if (!tags.length) return this\n\n return new RouterBuilder({\n ...this.zz$rb,\n tags: [...(this.zz$rb.tags ?? []), ...tags],\n })\n }\n\n use<\n UExtraContext extends\n | Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>>\n | undefined = undefined,\n >(\n middleware: Middleware<\n MergeContext<TContext, TExtraContext>,\n UExtraContext,\n unknown,\n unknown\n >,\n ): RouterBuilder<TContext, MergeContext<TExtraContext, UExtraContext>>\n\n use<\n UExtraContext extends\n | Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>>\n | undefined = undefined,\n UMappedInput = unknown,\n >(\n middleware: Middleware<\n MergeContext<TContext, TExtraContext>,\n UExtraContext,\n UMappedInput,\n unknown\n >,\n mapInput: MapInputMiddleware<unknown, UMappedInput>,\n ): RouterBuilder<TContext, MergeContext<TExtraContext, UExtraContext>>\n\n use(\n middleware: Middleware<any, any, any, any>,\n mapInput?: MapInputMiddleware<any, any>,\n ): RouterBuilder<any, any> {\n const middleware_ = mapInput\n ? decorateMiddleware(middleware).mapInput(mapInput)\n : middleware\n\n return new RouterBuilder({\n ...this.zz$rb,\n middlewares: [...(this.zz$rb.middlewares || []), middleware_],\n })\n }\n\n router<URouter extends Router<TContext>>(\n router: URouter,\n ): HandledRouter<URouter> {\n const handled: Router<TContext> = {}\n\n for (const key in router) {\n const item = router[key]\n\n if (isProcedure(item)) {\n const builderMiddlewares = this.zz$rb.middlewares ?? []\n const itemMiddlewares = item.zz$p.middlewares ?? []\n\n const middlewares = [\n ...builderMiddlewares,\n ...itemMiddlewares.filter(\n (item) => !builderMiddlewares.includes(item),\n ),\n ]\n\n const contract = DecoratedContractProcedure.decorate(\n item.zz$p.contract,\n ).addTags(...(this.zz$rb.tags ?? []))\n\n handled[key] = decorateProcedure({\n zz$p: {\n ...item.zz$p,\n contract: this.zz$rb.prefix\n ? contract.prefix(this.zz$rb.prefix)\n : contract,\n middlewares,\n },\n })\n } else {\n handled[key] = this.router(item as any)\n }\n }\n\n return handled as HandledRouter<URouter>\n }\n}\n","import {\n type ContractProcedure,\n type ContractRouter,\n isContractProcedure,\n} from '@orpc/contract'\nimport type { Middleware } from './middleware'\nimport { isProcedure } from './procedure'\nimport { ProcedureImplementer } from './procedure-implementer'\nimport type { RouterWithContract } from './router'\nimport type { Context } from './types'\n\nexport class RouterImplementer<\n TContext extends Context,\n TContract extends ContractRouter,\n> {\n constructor(\n public zz$ri: {\n contract: TContract\n },\n ) {}\n\n router(\n router: RouterWithContract<TContext, TContract>,\n ): RouterWithContract<TContext, TContract> {\n assertRouterImplementation(this.zz$ri.contract, router)\n\n return router\n }\n}\n\nexport type ChainedRouterImplementer<\n TContext extends Context,\n TContract extends ContractRouter,\n TExtraContext extends Context,\n> = {\n [K in keyof TContract]: TContract[K] extends ContractProcedure<\n infer UInputSchema,\n infer UOutputSchema\n >\n ? ProcedureImplementer<TContext, TExtraContext, UInputSchema, UOutputSchema>\n : TContract[K] extends ContractRouter\n ? ChainedRouterImplementer<TContext, TContract[K], TExtraContext>\n : never\n} & RouterImplementer<TContext, TContract>\n\nexport function chainRouterImplementer<\n TContext extends Context,\n TContract extends ContractRouter,\n TExtraContext extends Context,\n>(\n contract: TContract,\n middlewares?: Middleware<any, any, any, any>[],\n): ChainedRouterImplementer<TContext, TContract, TExtraContext> {\n const result: Record<string, unknown> = {}\n\n for (const key in contract) {\n const item = contract[key]\n\n if (isContractProcedure(item)) {\n result[key] = new ProcedureImplementer({\n contract: item,\n middlewares,\n })\n } else {\n result[key] = chainRouterImplementer(item as ContractRouter, middlewares)\n }\n }\n\n const implementer = new RouterImplementer({ contract })\n\n return Object.assign(implementer, result) as any\n}\n\nexport function assertRouterImplementation(\n contract: ContractRouter,\n router: RouterWithContract<any, any>,\n path: string[] = [],\n): void {\n for (const key in contract) {\n const currentPath = [...path, key]\n const contractItem = contract[key]\n const routerItem = router[key]\n\n if (!routerItem) {\n throw new Error(\n `Missing implementation for procedure at [${currentPath.join('.')}]`,\n )\n }\n\n if (isContractProcedure(contractItem)) {\n if (isProcedure(routerItem)) {\n if (routerItem.zz$p.contract !== contractItem) {\n throw new Error(\n `Mismatch implementation for procedure at [${currentPath.join('.')}]`,\n )\n }\n } else {\n throw new Error(\n `Mismatch implementation for procedure at [${currentPath.join('.')}]`,\n )\n }\n } else {\n assertRouterImplementation(\n contractItem as ContractRouter,\n routerItem as any,\n currentPath,\n )\n }\n }\n}\n","import { Builder } from './builder'\n\nexport * from './builder'\nexport * from '@orpc/shared/error'\nexport * from './middleware'\nexport * from './procedure'\nexport * from './procedure-caller'\nexport * from './procedure-builder'\nexport * from './procedure-implementer'\nexport * from './router'\nexport * from './router-caller'\nexport * from './router-implementer'\nexport * from './types'\nexport * from './utils'\n\nexport const os = new Builder<undefined | Record<string, unknown>, undefined>()\n","import {\n type ContractProcedure,\n type ContractRouter,\n isContractProcedure,\n} from '@orpc/contract'\nimport {\n type DecoratedProcedure,\n type Procedure,\n isProcedure,\n} from './procedure'\nimport type { Context } from './types'\n\nexport interface Router<TContext extends Context> {\n [k: string]: Procedure<TContext, any, any, any, any> | Router<TContext>\n}\n\nexport type HandledRouter<TRouter extends Router<any>> = {\n [K in keyof TRouter]: TRouter[K] extends Procedure<\n infer UContext,\n infer UExtraContext,\n infer UInputSchema,\n infer UOutputSchema,\n infer UHandlerOutput\n >\n ? DecoratedProcedure<\n UContext,\n UExtraContext,\n UInputSchema,\n UOutputSchema,\n UHandlerOutput\n >\n : TRouter[K] extends Router<any>\n ? HandledRouter<TRouter[K]>\n : never\n}\n\nexport type RouterWithContract<\n TContext extends Context,\n TContract extends ContractRouter,\n> = {\n [K in keyof TContract]: TContract[K] extends ContractProcedure<\n infer UInputSchema,\n infer UOutputSchema\n >\n ? Procedure<TContext, any, UInputSchema, UOutputSchema, any>\n : TContract[K] extends ContractRouter\n ? RouterWithContract<TContext, TContract[K]>\n : never\n}\n\nexport function toContractRouter(\n router: ContractRouter | Router<any>,\n): ContractRouter {\n const contract: ContractRouter = {}\n\n for (const key in router) {\n const item = router[key]\n\n if (isContractProcedure(item)) {\n contract[key] = item\n } else if (isProcedure(item)) {\n contract[key] = item.zz$p.contract\n } else {\n contract[key] = toContractRouter(item as any)\n }\n }\n\n return contract\n}\n","import type {} from '@orpc/contract'\nimport { type Procedure, isProcedure } from './procedure'\nimport { type ProcedureCaller, createProcedureCaller } from './procedure-caller'\nimport type { Router } from './router'\nimport type { Meta, Promisable } from './types'\nimport {} from './utils'\n\nexport interface CreateRouterCallerOptions<\n TRouter extends Router<any>,\n TValidate extends boolean,\n> {\n router: TRouter\n\n /**\n * The context used when calling the procedure.\n */\n context: TRouter extends Router<infer UContext> ? UContext : never\n\n /**\n * Helpful hooks to do some logics on specific time.\n */\n hooks?: (\n context: TRouter extends Router<infer UContext> ? UContext : never,\n meta: Meta<unknown>,\n ) => Promisable<void>\n\n /**\n * This is helpful for logging and analytics.\n */\n basePath?: string[]\n\n /**\n * This flag helpful when you want bypass some logics not necessary to internal server calls.\n *\n * @default true\n */\n internal?: boolean\n\n /**\n * Indicate whether validate input and output.\n *\n * @default true\n */\n validate?: TValidate\n}\n\nexport type RouterCaller<\n TRouter extends Router<any>,\n TValidate extends boolean,\n> = {\n [K in keyof TRouter]: TRouter[K] extends Procedure<any, any, any, any, any>\n ? ProcedureCaller<TRouter[K], TValidate>\n : TRouter[K] extends Router<any>\n ? RouterCaller<TRouter[K], TValidate>\n : never\n}\n\nexport function createRouterCaller<\n TRouter extends Router<any>,\n TValidate extends boolean = true,\n>(\n options: CreateRouterCallerOptions<TRouter, TValidate>,\n): RouterCaller<TRouter, TValidate> {\n const internal = options.internal ?? true\n const validate = options.validate ?? true\n\n const caller: Record<string, unknown> = {}\n\n for (const key in options.router) {\n const path = [...(options.basePath ?? []), key]\n const item = options.router[key]\n\n if (isProcedure(item)) {\n caller[key] = createProcedureCaller({\n procedure: item,\n context: options.context as any,\n hooks: options.hooks as any,\n path: path,\n internal,\n validate,\n })\n } else {\n caller[key] = createRouterCaller({\n router: item as any,\n context: options.context,\n hooks: options.hooks,\n basePath: path,\n internal,\n validate,\n })\n }\n }\n\n return caller as RouterCaller<TRouter, TValidate>\n}\n"],"mappings":";;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EAOA,uBAAAA;AAAA,OACK;;;ACTP;AAAA,EAEE;AAAA,OAKK;;;ACOA,IAAM,uBAAN,MAAM,sBAKX;AAAA,EACA,YACS,OAIP;AAJO;AAAA,EAIN;AAAA,EAwCH,IACE,YACA,UAC0C;AAC1C,UAAM,cAAc,WAChB,mBAAmB,UAAU,EAAE,SAAS,QAAQ,IAChD;AAEJ,WAAO,IAAI,sBAAqB;AAAA,MAC9B,GAAG,KAAK;AAAA,MACR,aAAa,CAAC,GAAI,KAAK,MAAM,eAAe,CAAC,GAAI,WAAW;AAAA,IAC9D,CAAC;AAAA,EACH;AAAA,EAEA,QACE,SAaA;AACA,WAAO,kBAAkB;AAAA,MACvB,MAAM;AAAA,QACJ,aAAa,KAAK,MAAM;AAAA,QACxB,UAAU,KAAK,MAAM;AAAA,QACrB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;ADrFO,IAAM,mBAAN,MAAM,kBAKX;AAAA,EACA,YACS,OAIP;AAJO;AAAA,EAIN;AAAA;AAAA;AAAA;AAAA,EAMH,MACE,MACwE;AACxE,WAAO,IAAI,kBAAiB;AAAA,MAC1B,GAAG,KAAK;AAAA,MACR,UAAU,2BAA2B,SAAS,KAAK,MAAM,QAAQ,EAAE;AAAA,QACjE;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,MACE,QACA,SACmE;AACnE,WAAO,IAAI,kBAAiB;AAAA,MAC1B,GAAG,KAAK;AAAA,MACR,UAAU,2BAA2B,SAAS,KAAK,MAAM,QAAQ,EAAE;AAAA,QACj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IAAI,GAAG;AACrB,aAAO,GAAG,IAAI,sBAAsB;AAAA,QAClC,WAAW;AAAA,QACX,SAAS,QAAQ;AAAA,QACjB,OAAO,QAAQ;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,aAAO,GAAG,IAAI,mBAAmB;AAAA,QAC/B,QAAQ;AAAA,QACR,SAAS,QAAQ;AAAA,QACjB,OAAO,QAAQ;AAAA,QACf,UAAU;AAAA,QACV;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;;;AF/EO,IAAM,KAAK,IAAI,QAAwD;","names":["isContractProcedure","DecoratedContractProcedure","item","DecoratedContractProcedure","isContractProcedure","isContractProcedure","isContractProcedure"]}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { type PartialOnUndefinedDeep } from '@orpc/shared';
|
2
|
+
import type { Router } from '../router';
|
3
|
+
import type { Meta, Promisable } from '../types';
|
4
|
+
export interface CreateFetchHandlerOptions<TRouter extends Router<any>> {
|
5
|
+
router: TRouter;
|
6
|
+
hooks?: (context: TRouter extends Router<infer UContext> ? UContext : never, meta: Meta<unknown>) => Promisable<void>;
|
7
|
+
/**
|
8
|
+
* It will help improve the cold start time. But it will increase the performance.
|
9
|
+
*
|
10
|
+
* @default false
|
11
|
+
*/
|
12
|
+
serverless?: boolean;
|
13
|
+
}
|
14
|
+
export declare function createFetchHandler<TRouter extends Router<any>>(options: CreateFetchHandlerOptions<TRouter>): FetchHandler<TRouter>;
|
15
|
+
export type FetchHandlerOptions<TRouter extends Router<any>> = {
|
16
|
+
/**
|
17
|
+
* The request need to be handled.
|
18
|
+
*/
|
19
|
+
request: Request;
|
20
|
+
/**
|
21
|
+
* Remove the prefix from the request path.
|
22
|
+
*
|
23
|
+
* @example /orpc
|
24
|
+
* @example /api
|
25
|
+
*/
|
26
|
+
prefix?: string;
|
27
|
+
} & PartialOnUndefinedDeep<{
|
28
|
+
/**
|
29
|
+
* The context used to handle the request.
|
30
|
+
*/
|
31
|
+
context: TRouter extends Router<infer UContext> ? UContext : never;
|
32
|
+
}>;
|
33
|
+
export interface FetchHandler<TRouter extends Router<any>> {
|
34
|
+
(options: FetchHandlerOptions<TRouter>): Promise<Response>;
|
35
|
+
}
|
36
|
+
//# sourceMappingURL=fetch.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/adapters/fetch.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,sBAAsB,EAI5B,MAAM,cAAc,CAAA;AAYrB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAGhD,MAAM,WAAW,yBAAyB,CAAC,OAAO,SAAS,MAAM,CAAC,GAAG,CAAC;IACpE,MAAM,EAAE,OAAO,CAAA;IAEf,KAAK,CAAC,EAAE,CACN,OAAO,EAAE,OAAO,SAAS,MAAM,CAAC,MAAM,QAAQ,CAAC,GAAG,QAAQ,GAAG,KAAK,EAClE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,KAChB,UAAU,CAAC,IAAI,CAAC,CAAA;IAErB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,SAAS,MAAM,CAAC,GAAG,CAAC,EAC5D,OAAO,EAAE,yBAAyB,CAAC,OAAO,CAAC,GAC1C,YAAY,CAAC,OAAO,CAAC,CAwJvB;AAMD,MAAM,MAAM,mBAAmB,CAAC,OAAO,SAAS,MAAM,CAAC,GAAG,CAAC,IAAI;IAC7D;;OAEG;IACH,OAAO,EAAE,OAAO,CAAA;IAEhB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,GAAG,sBAAsB,CAAC;IACzB;;OAEG;IACH,OAAO,EAAE,OAAO,SAAS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