orpc-fn 0.2.0 → 0.3.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/README.md +28 -7
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +56 -0
- package/dist/cli.js.map +1 -0
- package/dist/create-fn.d.ts +3 -3
- package/dist/create-fn.d.ts.map +1 -1
- package/dist/create-fn.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/live/fn-live.d.ts +9 -5
- package/dist/live/fn-live.d.ts.map +1 -1
- package/dist/live/fn-live.js.map +1 -1
- package/dist/live/pub-sub.d.ts +5 -1
- package/dist/live/pub-sub.d.ts.map +1 -1
- package/dist/live/pub-sub.js +9 -2
- package/dist/live/pub-sub.js.map +1 -1
- package/dist/mcp/core.d.ts +41 -0
- package/dist/mcp/core.d.ts.map +1 -0
- package/dist/mcp/core.js +61 -0
- package/dist/mcp/core.js.map +1 -0
- package/dist/mcp/sdk.d.ts +8 -16
- package/dist/mcp/sdk.d.ts.map +1 -1
- package/dist/mcp/sdk.js +10 -78
- package/dist/mcp/sdk.js.map +1 -1
- package/dist/mcp/server.d.ts +11 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +13 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/router.d.ts +8 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +13 -0
- package/dist/router.js.map +1 -1
- package/dist/types.d.ts +16 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +15 -2
- package/src/cli.ts +68 -0
- package/src/create-fn.ts +3 -4
- package/src/index.ts +2 -1
- package/src/live/fn-live.ts +9 -5
- package/src/live/pub-sub.ts +13 -4
- package/src/mcp/core.ts +102 -0
- package/src/mcp/sdk.ts +20 -102
- package/src/mcp/server.ts +35 -0
- package/src/router.ts +19 -0
- package/src/types.ts +24 -42
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type AnyRouter, type InferRouterInitialContext } from '@orpc/server';
|
|
2
|
+
import { listTools, type McpTool, type ProcedureFilter } from '../mcp.js';
|
|
3
|
+
/** Text-only tool result: the shape both MCP SDK majors accept. */
|
|
4
|
+
export type TextToolResult = {
|
|
5
|
+
content: {
|
|
6
|
+
type: 'text';
|
|
7
|
+
text: string;
|
|
8
|
+
}[];
|
|
9
|
+
isError?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type RegisterMcpToolsOptions<R extends AnyRouter, TResult> = {
|
|
12
|
+
/** Tool exposure must be an explicit application choice. */
|
|
13
|
+
filter: ProcedureFilter;
|
|
14
|
+
context: (request: {
|
|
15
|
+
name: string;
|
|
16
|
+
signal: AbortSignal;
|
|
17
|
+
}) => InferRouterInitialContext<R> | Promise<InferRouterInitialContext<R>>;
|
|
18
|
+
readOnly?: ProcedureFilter;
|
|
19
|
+
name?: NonNullable<Parameters<typeof listTools>[1]>['name'];
|
|
20
|
+
formatResult?: (value: unknown, tool: McpTool) => TResult | Promise<TResult>;
|
|
21
|
+
};
|
|
22
|
+
/** Default protocol result: JSON/text. Provide formatResult for other MCP content. */
|
|
23
|
+
export declare function formatMcpResult(value: unknown): TextToolResult;
|
|
24
|
+
/** @internal SDK-independent `tools/list` and `tools/call` behind both adapters. */
|
|
25
|
+
export declare function createToolHandlers<R extends AnyRouter, TResult>(router: R, options: RegisterMcpToolsOptions<R, TResult>): {
|
|
26
|
+
names: readonly string[];
|
|
27
|
+
list: () => {
|
|
28
|
+
tools: {
|
|
29
|
+
description?: string;
|
|
30
|
+
annotations: {
|
|
31
|
+
readOnlyHint: boolean;
|
|
32
|
+
};
|
|
33
|
+
name: string;
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: 'object';
|
|
36
|
+
};
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
call: (name: string, args: Record<string, unknown> | undefined, signal: AbortSignal) => Promise<TResult | TextToolResult>;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/mcp/core.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,SAAS,EACd,KAAK,yBAAyB,EAE9B,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,SAAS,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAEzE,mEAAmE;AACnE,MAAM,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACzC,OAAO,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO,IAAI;IACnE,4DAA4D;IAC5D,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,CAAC,OAAO,EAAE;QAClB,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,WAAW,CAAA;KACnB,KAAK,yBAAyB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1E,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B,IAAI,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IAC3D,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC5E,CAAA;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAQ9D;AAOD,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO,EAC9D,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,uBAAuB,CAAC,CAAC,EAAE,OAAO,CAAC;IAwB3C,KAAK,EAAuB,SAAS,MAAM,EAAE;IAC7C,IAAI;QAAW,KAAK;;;;;;;sBALkB,QAAQ;;;;IAM9C,IAAI,SACG,MAAM,QACN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,UACjC,WAAW,KACjB,OAAO,CAAC,OAAO,GAAG,cAAc,CAAC;EA0BrC"}
|
package/dist/mcp/core.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { call } from '@orpc/server';
|
|
2
|
+
import { isObjectJsonSchema } from '../json-schema.js';
|
|
3
|
+
import { listTools } from '../mcp.js';
|
|
4
|
+
/** Default protocol result: JSON/text. Provide formatResult for other MCP content. */
|
|
5
|
+
export function formatMcpResult(value) {
|
|
6
|
+
const text = typeof value === 'string'
|
|
7
|
+
? value
|
|
8
|
+
: (JSON.stringify(value, (_key, item) => typeof item === 'bigint' ? item.toString() : item) ?? 'null');
|
|
9
|
+
return { content: [{ type: 'text', text }] };
|
|
10
|
+
}
|
|
11
|
+
const errorResult = (text) => ({
|
|
12
|
+
content: [{ type: 'text', text }],
|
|
13
|
+
isError: true
|
|
14
|
+
});
|
|
15
|
+
/** @internal SDK-independent `tools/list` and `tools/call` behind both adapters. */
|
|
16
|
+
export function createToolHandlers(router, options) {
|
|
17
|
+
const definitions = listTools(router, {
|
|
18
|
+
filter: options.filter,
|
|
19
|
+
...(options.readOnly ? { readOnly: options.readOnly } : {}),
|
|
20
|
+
...(options.name ? { name: options.name } : {})
|
|
21
|
+
});
|
|
22
|
+
const tools = new Map(definitions.map((tool) => [tool.name, tool]));
|
|
23
|
+
const descriptions = definitions.map((tool) => {
|
|
24
|
+
const inputSchema = tool.config.inputSchema?.['~standard'].jsonSchema.input() ?? { type: 'object', properties: {} };
|
|
25
|
+
if (!isObjectJsonSchema(inputSchema))
|
|
26
|
+
throw new TypeError(`orpc-fn: MCP tool ${tool.name} needs an object input`);
|
|
27
|
+
// MCP requires a top-level object; object unions retain their constraints.
|
|
28
|
+
return {
|
|
29
|
+
name: tool.name,
|
|
30
|
+
...tool.config,
|
|
31
|
+
inputSchema: { ...inputSchema, type: 'object' }
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
names: [...tools.keys()],
|
|
36
|
+
list: () => ({ tools: descriptions }),
|
|
37
|
+
call: async (name, args, signal) => {
|
|
38
|
+
const tool = tools.get(name);
|
|
39
|
+
if (!tool)
|
|
40
|
+
return errorResult(`Unknown tool: ${name}`);
|
|
41
|
+
try {
|
|
42
|
+
signal.throwIfAborted();
|
|
43
|
+
const validation = await tool.config.inputSchema?.['~standard'].validate(args ?? {});
|
|
44
|
+
if (validation?.issues)
|
|
45
|
+
return errorResult(validation.issues.map((issue) => issue.message).join('; '));
|
|
46
|
+
const context = await options.context({ name: tool.name, signal });
|
|
47
|
+
const result = await call(tool.procedure, validation?.value, {
|
|
48
|
+
context,
|
|
49
|
+
signal
|
|
50
|
+
});
|
|
51
|
+
return await (options.formatResult ?? formatMcpResult)(result, tool);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (signal.aborted)
|
|
55
|
+
throw error;
|
|
56
|
+
return errorResult(error instanceof Error ? error.message : String(error));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/mcp/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,IAAI,EACJ,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAsC,MAAM,WAAW,CAAA;AAoB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AAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAC1D,CAAA;gBACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;gBAClE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE;oBAC5D,OAAO;oBACP,MAAM;iBACN,CAAC,CAAA;gBACF,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,IAAI,eAAe,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YACrE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,MAAM,CAAC,OAAO;oBAAE,MAAM,KAAK,CAAA;gBAC/B,OAAO,WAAW,CACjB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACtD,CAAA;YACF,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC","sourcesContent":["import {\n\ttype AnyRouter,\n\ttype InferRouterInitialContext,\n\tcall\n} from '@orpc/server'\nimport { isObjectJsonSchema } from '../json-schema.js'\nimport { listTools, type McpTool, type ProcedureFilter } from '../mcp.js'\n\n/** Text-only tool result: the shape both MCP SDK majors accept. */\nexport type TextToolResult = {\n\tcontent: { type: 'text'; text: string }[]\n\tisError?: boolean\n}\n\nexport type RegisterMcpToolsOptions<R extends AnyRouter, TResult> = {\n\t/** Tool exposure must be an explicit application choice. */\n\tfilter: ProcedureFilter\n\tcontext: (request: {\n\t\tname: string\n\t\tsignal: AbortSignal\n\t}) => InferRouterInitialContext<R> | Promise<InferRouterInitialContext<R>>\n\treadOnly?: ProcedureFilter\n\tname?: NonNullable<Parameters<typeof listTools>[1]>['name']\n\tformatResult?: (value: unknown, tool: McpTool) => TResult | Promise<TResult>\n}\n\n/** Default protocol result: JSON/text. Provide formatResult for other MCP content. */\nexport function formatMcpResult(value: unknown): TextToolResult {\n\tconst text =\n\t\ttypeof value === 'string'\n\t\t\t? value\n\t\t\t: (JSON.stringify(value, (_key, item) =>\n\t\t\t\t\ttypeof item === 'bigint' ? item.toString() : item\n\t\t\t\t) ?? 'null')\n\treturn { content: [{ type: 'text', text }] }\n}\n\nconst errorResult = (text: string): TextToolResult => ({\n\tcontent: [{ type: 'text', text }],\n\tisError: true\n})\n\n/** @internal SDK-independent `tools/list` and `tools/call` behind both adapters. */\nexport function createToolHandlers<R extends AnyRouter, TResult>(\n\trouter: R,\n\toptions: RegisterMcpToolsOptions<R, TResult>\n) {\n\tconst definitions = listTools(router, {\n\t\tfilter: options.filter,\n\t\t...(options.readOnly ? { readOnly: options.readOnly } : {}),\n\t\t...(options.name ? { name: options.name } : {})\n\t})\n\tconst tools = new Map(definitions.map((tool) => [tool.name, tool]))\n\tconst descriptions = definitions.map((tool) => {\n\t\tconst inputSchema = tool.config.inputSchema?.[\n\t\t\t'~standard'\n\t\t].jsonSchema.input() ?? { type: 'object', properties: {} }\n\t\tif (!isObjectJsonSchema(inputSchema))\n\t\t\tthrow new TypeError(\n\t\t\t\t`orpc-fn: MCP tool ${tool.name} needs an object input`\n\t\t\t)\n\t\t// MCP requires a top-level object; object unions retain their constraints.\n\t\treturn {\n\t\t\tname: tool.name,\n\t\t\t...tool.config,\n\t\t\tinputSchema: { ...inputSchema, type: 'object' as const }\n\t\t}\n\t})\n\treturn {\n\t\tnames: [...tools.keys()] as readonly string[],\n\t\tlist: () => ({ tools: descriptions }),\n\t\tcall: async (\n\t\t\tname: string,\n\t\t\targs: Record<string, unknown> | undefined,\n\t\t\tsignal: AbortSignal\n\t\t): Promise<TResult | TextToolResult> => {\n\t\t\tconst tool = tools.get(name)\n\t\t\tif (!tool) return errorResult(`Unknown tool: ${name}`)\n\t\t\ttry {\n\t\t\t\tsignal.throwIfAborted()\n\t\t\t\tconst validation = await tool.config.inputSchema?.[\n\t\t\t\t\t'~standard'\n\t\t\t\t].validate(args ?? {})\n\t\t\t\tif (validation?.issues)\n\t\t\t\t\treturn errorResult(\n\t\t\t\t\t\tvalidation.issues.map((issue) => issue.message).join('; ')\n\t\t\t\t\t)\n\t\t\t\tconst context = await options.context({ name: tool.name, signal })\n\t\t\t\tconst result = await call(tool.procedure, validation?.value, {\n\t\t\t\t\tcontext,\n\t\t\t\t\tsignal\n\t\t\t\t})\n\t\t\t\treturn await (options.formatResult ?? formatMcpResult)(result, tool)\n\t\t\t} catch (error) {\n\t\t\t\tif (signal.aborted) throw error\n\t\t\t\treturn errorResult(\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
package/dist/mcp/sdk.d.ts
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
import { type CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}) => InferRouterInitialContext<R> | Promise<InferRouterInitialContext<R>>;
|
|
12
|
-
readOnly?: ProcedureFilter;
|
|
13
|
-
name?: NonNullable<Parameters<typeof listTools>[1]>['name'];
|
|
14
|
-
formatResult?: (value: unknown, tool: McpTool) => CallToolResult | Promise<CallToolResult>;
|
|
15
|
-
};
|
|
16
|
-
/** Default protocol result: JSON/text. Provide formatResult for other MCP content. */
|
|
17
|
-
export declare function formatMcpResult(value: unknown): CallToolResult;
|
|
18
|
-
/** Register on the SDK's low-level Server, or on McpServer.server. */
|
|
3
|
+
import type { AnyRouter } from '@orpc/server';
|
|
4
|
+
import { formatMcpResult, type RegisterMcpToolsOptions as CoreOptions } from './core.js';
|
|
5
|
+
export { formatMcpResult };
|
|
6
|
+
export type RegisterMcpToolsOptions<R extends AnyRouter> = CoreOptions<R, CallToolResult>;
|
|
7
|
+
/**
|
|
8
|
+
* Register on the SDK v1 low-level Server, or on McpServer.server. For SDK v2
|
|
9
|
+
* (`@modelcontextprotocol/server`) use `orpc-fn/mcp/server`.
|
|
10
|
+
*/
|
|
19
11
|
export declare function registerMcpTools<R extends AnyRouter>(server: Pick<Server, 'setRequestHandler'>, router: R, options: RegisterMcpToolsOptions<R>): readonly string[];
|
|
20
12
|
//# sourceMappingURL=sdk.d.ts.map
|
package/dist/mcp/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/mcp/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AACvE,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/mcp/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AACvE,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAEN,eAAe,EACf,KAAK,uBAAuB,IAAI,WAAW,EAC3C,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,eAAe,EAAE,CAAA;AAE1B,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,SAAS,IAAI,WAAW,CACrE,CAAC,EACD,cAAc,CACd,CAAA;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,EACnD,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACzC,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACjC,SAAS,MAAM,EAAE,CAOnB"}
|
package/dist/mcp/sdk.js
CHANGED
|
@@ -1,82 +1,14 @@
|
|
|
1
1
|
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
? value
|
|
9
|
-
: (JSON.stringify(value, (_key, item) => typeof item === 'bigint' ? item.toString() : item) ?? 'null');
|
|
10
|
-
return { content: [{ type: 'text', text }] };
|
|
11
|
-
}
|
|
12
|
-
/** Register on the SDK's low-level Server, or on McpServer.server. */
|
|
2
|
+
import { createToolHandlers, formatMcpResult } from './core.js';
|
|
3
|
+
export { formatMcpResult };
|
|
4
|
+
/**
|
|
5
|
+
* Register on the SDK v1 low-level Server, or on McpServer.server. For SDK v2
|
|
6
|
+
* (`@modelcontextprotocol/server`) use `orpc-fn/mcp/server`.
|
|
7
|
+
*/
|
|
13
8
|
export function registerMcpTools(server, router, options) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
const tools = new Map(definitions.map((tool) => [tool.name, tool]));
|
|
20
|
-
const descriptions = definitions.map((tool) => {
|
|
21
|
-
const inputSchema = tool.config.inputSchema?.['~standard'].jsonSchema.input() ?? { type: 'object', properties: {} };
|
|
22
|
-
if (!isObjectJsonSchema(inputSchema))
|
|
23
|
-
throw new TypeError(`orpc-fn: MCP tool ${tool.name} needs an object input`);
|
|
24
|
-
// MCP requires a top-level object; object unions retain their constraints.
|
|
25
|
-
return {
|
|
26
|
-
name: tool.name,
|
|
27
|
-
...tool.config,
|
|
28
|
-
inputSchema: { ...inputSchema, type: 'object' }
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
server.setRequestHandler(ListToolsRequestSchema, () => ({
|
|
32
|
-
tools: descriptions
|
|
33
|
-
}));
|
|
34
|
-
server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
35
|
-
const tool = tools.get(request.params.name);
|
|
36
|
-
if (!tool)
|
|
37
|
-
return {
|
|
38
|
-
content: [
|
|
39
|
-
{ type: 'text', text: `Unknown tool: ${request.params.name}` }
|
|
40
|
-
],
|
|
41
|
-
isError: true
|
|
42
|
-
};
|
|
43
|
-
try {
|
|
44
|
-
extra.signal.throwIfAborted();
|
|
45
|
-
const validation = await tool.config.inputSchema?.['~standard'].validate(request.params.arguments ?? {});
|
|
46
|
-
if (validation?.issues)
|
|
47
|
-
return {
|
|
48
|
-
content: [
|
|
49
|
-
{
|
|
50
|
-
type: 'text',
|
|
51
|
-
text: validation.issues.map((issue) => issue.message).join('; ')
|
|
52
|
-
}
|
|
53
|
-
],
|
|
54
|
-
isError: true
|
|
55
|
-
};
|
|
56
|
-
const context = await options.context({
|
|
57
|
-
name: tool.name,
|
|
58
|
-
signal: extra.signal
|
|
59
|
-
});
|
|
60
|
-
const result = await call(tool.procedure, validation?.value, {
|
|
61
|
-
context,
|
|
62
|
-
signal: extra.signal
|
|
63
|
-
});
|
|
64
|
-
return await (options.formatResult ?? formatMcpResult)(result, tool);
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
if (extra.signal.aborted)
|
|
68
|
-
throw error;
|
|
69
|
-
return {
|
|
70
|
-
content: [
|
|
71
|
-
{
|
|
72
|
-
type: 'text',
|
|
73
|
-
text: error instanceof Error ? error.message : String(error)
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
isError: true
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
return [...tools.keys()];
|
|
9
|
+
const handlers = createToolHandlers(router, options);
|
|
10
|
+
server.setRequestHandler(ListToolsRequestSchema, handlers.list);
|
|
11
|
+
server.setRequestHandler(CallToolRequestSchema, (request, extra) => handlers.call(request.params.name, request.params.arguments, extra.signal));
|
|
12
|
+
return handlers.names;
|
|
81
13
|
}
|
|
82
14
|
//# sourceMappingURL=sdk.js.map
|
package/dist/mcp/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/mcp/sdk.ts"],"names":[],"mappings":"AACA,OAAO,EACN,qBAAqB,EACrB,sBAAsB,EAEtB,MAAM,oCAAoC,CAAA;
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/mcp/sdk.ts"],"names":[],"mappings":"AACA,OAAO,EACN,qBAAqB,EACrB,sBAAsB,EAEtB,MAAM,oCAAoC,CAAA;AAE3C,OAAO,EACN,kBAAkB,EAClB,eAAe,EAEf,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,eAAe,EAAE,CAAA;AAO1B;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC/B,MAAyC,EACzC,MAAS,EACT,OAAmC;IAEnC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpD,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC/D,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAClE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAC1E,CAAA;IACD,OAAO,QAAQ,CAAC,KAAK,CAAA;AACtB,CAAC","sourcesContent":["import type { Server } from '@modelcontextprotocol/sdk/server/index.js'\nimport {\n\tCallToolRequestSchema,\n\tListToolsRequestSchema,\n\ttype CallToolResult\n} from '@modelcontextprotocol/sdk/types.js'\nimport type { AnyRouter } from '@orpc/server'\nimport {\n\tcreateToolHandlers,\n\tformatMcpResult,\n\ttype RegisterMcpToolsOptions as CoreOptions\n} from './core.js'\n\nexport { formatMcpResult }\n\nexport type RegisterMcpToolsOptions<R extends AnyRouter> = CoreOptions<\n\tR,\n\tCallToolResult\n>\n\n/**\n * Register on the SDK v1 low-level Server, or on McpServer.server. For SDK v2\n * (`@modelcontextprotocol/server`) use `orpc-fn/mcp/server`.\n */\nexport function registerMcpTools<R extends AnyRouter>(\n\tserver: Pick<Server, 'setRequestHandler'>,\n\trouter: R,\n\toptions: RegisterMcpToolsOptions<R>\n): readonly string[] {\n\tconst handlers = createToolHandlers(router, options)\n\tserver.setRequestHandler(ListToolsRequestSchema, handlers.list)\n\tserver.setRequestHandler(CallToolRequestSchema, (request, extra) =>\n\t\thandlers.call(request.params.name, request.params.arguments, extra.signal)\n\t)\n\treturn handlers.names\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CallToolResult, Server } from '@modelcontextprotocol/server';
|
|
2
|
+
import type { AnyRouter } from '@orpc/server';
|
|
3
|
+
import { formatMcpResult, type RegisterMcpToolsOptions as CoreOptions } from './core.js';
|
|
4
|
+
export { formatMcpResult };
|
|
5
|
+
export type RegisterMcpToolsOptions<R extends AnyRouter> = CoreOptions<R, CallToolResult>;
|
|
6
|
+
/**
|
|
7
|
+
* Register on the SDK v2 (`@modelcontextprotocol/server`) low-level Server, or
|
|
8
|
+
* on McpServer.server. Declare `capabilities: { tools: {} }` on the Server.
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerMcpTools<R extends AnyRouter>(server: Pick<Server, 'setRequestHandler'>, router: R, options: RegisterMcpToolsOptions<R>): readonly string[];
|
|
11
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAEN,eAAe,EACf,KAAK,uBAAuB,IAAI,WAAW,EAC3C,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,eAAe,EAAE,CAAA;AAE1B,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,SAAS,IAAI,WAAW,CACrE,CAAC,EACD,cAAc,CACd,CAAA;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,EACnD,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACzC,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACjC,SAAS,MAAM,EAAE,CAWnB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createToolHandlers, formatMcpResult } from './core.js';
|
|
2
|
+
export { formatMcpResult };
|
|
3
|
+
/**
|
|
4
|
+
* Register on the SDK v2 (`@modelcontextprotocol/server`) low-level Server, or
|
|
5
|
+
* on McpServer.server. Declare `capabilities: { tools: {} }` on the Server.
|
|
6
|
+
*/
|
|
7
|
+
export function registerMcpTools(server, router, options) {
|
|
8
|
+
const handlers = createToolHandlers(router, options);
|
|
9
|
+
server.setRequestHandler('tools/list', handlers.list);
|
|
10
|
+
server.setRequestHandler('tools/call', (request, ctx) => handlers.call(request.params.name, request.params.arguments, ctx.mcpReq.signal));
|
|
11
|
+
return handlers.names;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,kBAAkB,EAClB,eAAe,EAEf,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,eAAe,EAAE,CAAA;AAO1B;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC/B,MAAyC,EACzC,MAAS,EACT,OAAmC;IAEnC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpD,MAAM,CAAC,iBAAiB,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;IACrD,MAAM,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CACvD,QAAQ,CAAC,IAAI,CACZ,OAAO,CAAC,MAAM,CAAC,IAAI,EACnB,OAAO,CAAC,MAAM,CAAC,SAAS,EACxB,GAAG,CAAC,MAAM,CAAC,MAAM,CACjB,CACD,CAAA;IACD,OAAO,QAAQ,CAAC,KAAK,CAAA;AACtB,CAAC","sourcesContent":["import type { CallToolResult, Server } from '@modelcontextprotocol/server'\nimport type { AnyRouter } from '@orpc/server'\nimport {\n\tcreateToolHandlers,\n\tformatMcpResult,\n\ttype RegisterMcpToolsOptions as CoreOptions\n} from './core.js'\n\nexport { formatMcpResult }\n\nexport type RegisterMcpToolsOptions<R extends AnyRouter> = CoreOptions<\n\tR,\n\tCallToolResult\n>\n\n/**\n * Register on the SDK v2 (`@modelcontextprotocol/server`) low-level Server, or\n * on McpServer.server. Declare `capabilities: { tools: {} }` on the Server.\n */\nexport function registerMcpTools<R extends AnyRouter>(\n\tserver: Pick<Server, 'setRequestHandler'>,\n\trouter: R,\n\toptions: RegisterMcpToolsOptions<R>\n): readonly string[] {\n\tconst handlers = createToolHandlers(router, options)\n\tserver.setRequestHandler('tools/list', handlers.list)\n\tserver.setRequestHandler('tools/call', (request, ctx) =>\n\t\thandlers.call(\n\t\t\trequest.params.name,\n\t\t\trequest.params.arguments,\n\t\t\tctx.mcpReq.signal\n\t\t)\n\t)\n\treturn handlers.names\n}\n"]}
|
package/dist/router.d.ts
CHANGED
|
@@ -14,4 +14,12 @@ export declare function createRouter<T extends AnyRouter>(routes: T): Readonly<T
|
|
|
14
14
|
export declare function createStreamManifest(router: AnyRouter): readonly (readonly string[])[];
|
|
15
15
|
/** Resolve lazy routers before generating the same serializable path manifest. */
|
|
16
16
|
export declare function createStreamManifestAsync(router: AnyRouter): Promise<readonly (readonly string[])[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Deterministic module source for a stream manifest: paths sorted, `json`
|
|
19
|
+
* as an array, `ts` as `export const <name>`. Used by `orpc-fn stream-manifest`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function renderStreamManifest(paths: readonly (readonly string[])[], options: {
|
|
22
|
+
format: 'json' | 'ts';
|
|
23
|
+
name?: string | undefined;
|
|
24
|
+
}): string;
|
|
17
25
|
//# sourceMappingURL=router.d.ts.map
|
package/dist/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,SAAS,EAId,MAAM,cAAc,CAAA;AAGrB;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAExE;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,SAAS,GACf,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAahC;AAED,kFAAkF;AAClF,wBAAsB,yBAAyB,CAC9C,MAAM,EAAE,SAAS,GACf,OAAO,CAAC,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,CASzC"}
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,SAAS,EAId,MAAM,cAAc,CAAA;AAGrB;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAExE;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,SAAS,GACf,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAahC;AAED,kFAAkF;AAClF,wBAAsB,yBAAyB,CAC9C,MAAM,EAAE,SAAS,GACf,OAAO,CAAC,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,CASzC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,EACrC,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC3D,MAAM,CAUR"}
|
package/dist/router.js
CHANGED
|
@@ -33,4 +33,17 @@ export async function createStreamManifestAsync(router) {
|
|
|
33
33
|
});
|
|
34
34
|
return paths;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Deterministic module source for a stream manifest: paths sorted, `json`
|
|
38
|
+
* as an array, `ts` as `export const <name>`. Used by `orpc-fn stream-manifest`.
|
|
39
|
+
*/
|
|
40
|
+
export function renderStreamManifest(paths, options) {
|
|
41
|
+
const lines = paths
|
|
42
|
+
.map((path) => `\t[${path.map((segment) => JSON.stringify(segment)).join(', ')}]`)
|
|
43
|
+
.sort();
|
|
44
|
+
const array = lines.length ? `[\n${lines.join(',\n')}\n]` : '[]';
|
|
45
|
+
if (options.format === 'json')
|
|
46
|
+
return `${array}\n`;
|
|
47
|
+
return `// Generated by \`orpc-fn stream-manifest\`. Do not edit.\nexport const ${options.name ?? 'streamPaths'}: readonly (readonly string[])[] = ${array}\n`;
|
|
48
|
+
}
|
|
36
49
|
//# sourceMappingURL=router.js.map
|
package/dist/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,yBAAyB,EACzB,0BAA0B,EAC1B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAsB,MAAS;IAC1D,OAAO,MAAM,CAAA;AACd,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,oBAAoB,CACnC,MAAiB;IAEjB,MAAM,KAAK,GAAe,EAAE,CAAA;IAC5B,MAAM,UAAU,GAAG,0BAA0B,CAC5C,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,EACpB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE;QACtB,IAAI,UAAU,CAAC,QAAwB,CAAC,CAAC,MAAM;YAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACvE,CAAC,CACD,CAAA;IACD,IAAI,UAAU,CAAC,MAAM;QACpB,MAAM,IAAI,SAAS,CAClB,yDAAyD,CACzD,CAAA;IACF,OAAO,KAAK,CAAA;AACb,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC9C,MAAiB;IAEjB,MAAM,KAAK,GAAe,EAAE,CAAA;IAC5B,MAAM,yBAAyB,CAC9B,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,EACpB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE;QACtB,IAAI,UAAU,CAAC,QAAwB,CAAC,CAAC,MAAM;YAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACvE,CAAC,CACD,CAAA;IACD,OAAO,KAAK,CAAA;AACb,CAAC","sourcesContent":["import {\n\ttype AnyRouter,\n\ttype AnyProcedure,\n\tresolveContractProcedures,\n\ttraverseContractProcedures\n} from '@orpc/server'\nimport { readFnMeta } from './meta.js'\n\n/**\n * Creates a router object from routes or nested routers.\n * Simply returns the routes as a const object for type inference.\n *\n * @example\n * ```ts\n * const items = createRouter({ getItem, updateItem })\n * export const api = createRouter({ metabase, items })\n * ```\n */\nexport function createRouter<T extends AnyRouter>(routes: T): Readonly<T> {\n\treturn routes\n}\n\n/** Serialize these paths to a frontend module; this helper belongs on the server. */\nexport function createStreamManifest(\n\trouter: AnyRouter\n): readonly (readonly string[])[] {\n\tconst paths: string[][] = []\n\tconst unresolved = traverseContractProcedures(\n\t\t{ router, path: [] },\n\t\t({ contract, path }) => {\n\t\t\tif (readFnMeta(contract as AnyProcedure).stream) paths.push([...path])\n\t\t}\n\t)\n\tif (unresolved.length)\n\t\tthrow new TypeError(\n\t\t\t'orpc-fn: lazy routers require createStreamManifestAsync'\n\t\t)\n\treturn paths\n}\n\n/** Resolve lazy routers before generating the same serializable path manifest. */\nexport async function createStreamManifestAsync(\n\trouter: AnyRouter\n): Promise<readonly (readonly string[])[]> {\n\tconst paths: string[][] = []\n\tawait resolveContractProcedures(\n\t\t{ router, path: [] },\n\t\t({ contract, path }) => {\n\t\t\tif (readFnMeta(contract as AnyProcedure).stream) paths.push([...path])\n\t\t}\n\t)\n\treturn paths\n}\n"]}
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,yBAAyB,EACzB,0BAA0B,EAC1B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAsB,MAAS;IAC1D,OAAO,MAAM,CAAA;AACd,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,oBAAoB,CACnC,MAAiB;IAEjB,MAAM,KAAK,GAAe,EAAE,CAAA;IAC5B,MAAM,UAAU,GAAG,0BAA0B,CAC5C,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,EACpB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE;QACtB,IAAI,UAAU,CAAC,QAAwB,CAAC,CAAC,MAAM;YAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACvE,CAAC,CACD,CAAA;IACD,IAAI,UAAU,CAAC,MAAM;QACpB,MAAM,IAAI,SAAS,CAClB,yDAAyD,CACzD,CAAA;IACF,OAAO,KAAK,CAAA;AACb,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC9C,MAAiB;IAEjB,MAAM,KAAK,GAAe,EAAE,CAAA;IAC5B,MAAM,yBAAyB,CAC9B,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,EACpB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE;QACtB,IAAI,UAAU,CAAC,QAAwB,CAAC,CAAC,MAAM;YAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACvE,CAAC,CACD,CAAA;IACD,OAAO,KAAK,CAAA;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,KAAqC,EACrC,OAA6D;IAE7D,MAAM,KAAK,GAAG,KAAK;SACjB,GAAG,CACH,CAAC,IAAI,EAAE,EAAE,CACR,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACnE;SACA,IAAI,EAAE,CAAA;IACR,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;IAChE,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,GAAG,KAAK,IAAI,CAAA;IAClD,OAAO,2EAA2E,OAAO,CAAC,IAAI,IAAI,aAAa,sCAAsC,KAAK,IAAI,CAAA;AAC/J,CAAC","sourcesContent":["import {\n\ttype AnyRouter,\n\ttype AnyProcedure,\n\tresolveContractProcedures,\n\ttraverseContractProcedures\n} from '@orpc/server'\nimport { readFnMeta } from './meta.js'\n\n/**\n * Creates a router object from routes or nested routers.\n * Simply returns the routes as a const object for type inference.\n *\n * @example\n * ```ts\n * const items = createRouter({ getItem, updateItem })\n * export const api = createRouter({ metabase, items })\n * ```\n */\nexport function createRouter<T extends AnyRouter>(routes: T): Readonly<T> {\n\treturn routes\n}\n\n/** Serialize these paths to a frontend module; this helper belongs on the server. */\nexport function createStreamManifest(\n\trouter: AnyRouter\n): readonly (readonly string[])[] {\n\tconst paths: string[][] = []\n\tconst unresolved = traverseContractProcedures(\n\t\t{ router, path: [] },\n\t\t({ contract, path }) => {\n\t\t\tif (readFnMeta(contract as AnyProcedure).stream) paths.push([...path])\n\t\t}\n\t)\n\tif (unresolved.length)\n\t\tthrow new TypeError(\n\t\t\t'orpc-fn: lazy routers require createStreamManifestAsync'\n\t\t)\n\treturn paths\n}\n\n/** Resolve lazy routers before generating the same serializable path manifest. */\nexport async function createStreamManifestAsync(\n\trouter: AnyRouter\n): Promise<readonly (readonly string[])[]> {\n\tconst paths: string[][] = []\n\tawait resolveContractProcedures(\n\t\t{ router, path: [] },\n\t\t({ contract, path }) => {\n\t\t\tif (readFnMeta(contract as AnyProcedure).stream) paths.push([...path])\n\t\t}\n\t)\n\treturn paths\n}\n\n/**\n * Deterministic module source for a stream manifest: paths sorted, `json`\n * as an array, `ts` as `export const <name>`. Used by `orpc-fn stream-manifest`.\n */\nexport function renderStreamManifest(\n\tpaths: readonly (readonly string[])[],\n\toptions: { format: 'json' | 'ts'; name?: string | undefined }\n): string {\n\tconst lines = paths\n\t\t.map(\n\t\t\t(path) =>\n\t\t\t\t`\\t[${path.map((segment) => JSON.stringify(segment)).join(', ')}]`\n\t\t)\n\t\t.sort()\n\tconst array = lines.length ? `[\\n${lines.join(',\\n')}\\n]` : '[]'\n\tif (options.format === 'json') return `${array}\\n`\n\treturn `// Generated by \\`orpc-fn stream-manifest\\`. Do not edit.\\nexport const ${options.name ?? 'streamPaths'}: readonly (readonly string[])[] = ${array}\\n`\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export type BuildProcedure = (options: {
|
|
|
58
58
|
export type RejectKeys<T, K extends PropertyKey, TMessage extends string> = {
|
|
59
59
|
[P in Extract<keyof T, K>]: TMessage;
|
|
60
60
|
};
|
|
61
|
+
/** Params every handler receives; extras may not reuse these names. */
|
|
62
|
+
type HandlerParamKey = 'input' | 'context' | 'call' | 'signal' | 'span' | 'logger' | 'errors' | 'lastEventId';
|
|
61
63
|
/**
|
|
62
64
|
* Handler extras must have known keys: an index signature would claim every
|
|
63
65
|
* handler param. Intersected into `createFn`'s options to reject it.
|
|
@@ -66,7 +68,7 @@ export type FiniteExtras<T> = T extends unknown ? string extends keyof T ? {
|
|
|
66
68
|
extras: 'orpc-fn: extras need known keys, not an index signature';
|
|
67
69
|
} : number extends keyof T ? {
|
|
68
70
|
extras: 'orpc-fn: extras need known keys, not an index signature';
|
|
69
|
-
} : Extract<keyof T,
|
|
71
|
+
} : Extract<keyof T, HandlerParamKey> extends never ? unknown : {
|
|
70
72
|
extras: 'orpc-fn: extras cannot shadow handler parameters';
|
|
71
73
|
} : never;
|
|
72
74
|
type ProcedureOf<TBuilder> = TBuilder extends {
|
|
@@ -123,7 +125,7 @@ export type GuardOptions<TGuards> = {
|
|
|
123
125
|
type MergeExtras<TShared, TScoped> = TShared extends unknown ? TScoped extends unknown ? Omit<TShared, keyof TScoped> & TScoped : never : never;
|
|
124
126
|
export type HandlerParams<TDef extends FnDefinition, TInput, TKey extends ProcedureKey<TDef>, TErrors extends ErrorMap = Record<never, never>> = DistributiveOmit<MergeExtras<TDef['extras'], TDef extends {
|
|
125
127
|
extrasByProcedure: infer E;
|
|
126
|
-
} ? TKey extends keyof E ? E[TKey] : object : object>,
|
|
128
|
+
} ? TKey extends keyof E ? E[TKey] : object : object>, HandlerParamKey> & {
|
|
127
129
|
input: TInput;
|
|
128
130
|
context: FnContext<TDef, TKey>;
|
|
129
131
|
/** Calls another procedure with this context and signal, in a child span. */
|
|
@@ -232,10 +234,18 @@ export type CompletedHookEvent<TProcedures extends Record<string, BuilderLike>,
|
|
|
232
234
|
context: InitialContextOf<TProcedures[K]>;
|
|
233
235
|
});
|
|
234
236
|
}[keyof TProcedures & string];
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Intersected into each scoped extras function's return type: rejects index
|
|
239
|
+
* signatures and handler-parameter names at the offending property. A
|
|
240
|
+
* top-level conditional over the whole map broke inference when zero-argument
|
|
241
|
+
* and context-reading functions were mixed.
|
|
242
|
+
*/
|
|
243
|
+
export type ScopedExtrasGuard<T> = (string extends keyof T ? {
|
|
244
|
+
'orpc-fn: scoped extras need finite keys': never;
|
|
245
|
+
} : number extends keyof T ? {
|
|
246
|
+
'orpc-fn: scoped extras need finite keys': never;
|
|
247
|
+
} : unknown) & {
|
|
248
|
+
[K in HandlerParamKey]?: never;
|
|
239
249
|
};
|
|
240
250
|
export {};
|
|
241
251
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,MAAM,EACN,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EACX,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,KAAK,EACL,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAA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AAA;AAE7B;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,MAAM,SAAS,MAAM,CAAC,GACvD;IAAE,yCAAyC,EAAE,KAAK,CAAA;CAAE,GACpD,MAAM,SAAS,MAAM,CAAC,GACrB;IAAE,yCAAyC,EAAE,KAAK,CAAA;CAAE,GACpD,OAAO,CAAC,GAAG;KAAG,CAAC,IAAI,eAAe,CAAC,CAAC,EAAE,KAAK;CAAE,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAkFA,oFAAoF;AACpF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC,MAAM;IACN,QAAQ;IACR,SAAS;IACT,aAAa;IACb,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB,gBAAgB;IAChB,iBAAiB;IACjB,MAAM;CACsC,CAAA;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IACnC,GAAG,iBAAiB;IACpB,MAAM;IACN,WAAW;IACX,OAAO;IACP,QAAQ;IACR,SAAS;IACT,MAAM;IACN,aAAa;IACb,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,gBAAgB;CACP,CAAA","sourcesContent":["import type {\n\tAnySchema,\n\tErrorMap,\n\tInferSchemaInput,\n\tInferSchemaOutput,\n\tMergedErrorMap,\n\tSchema\n} from '@orpc/contract'\nimport type {\n\tAnyProcedure,\n\tDecoratedProcedure,\n\tProcedure,\n\tRoute\n} from '@orpc/server'\nimport type { createORPCErrorConstructorMap } from '@orpc/server'\nimport type { StoredFnMeta } from './meta.js'\nimport type { NativeErrors, NativeMeta } from './compatibility.js'\nimport type { BoundCall } from './bound-call.js'\nimport type { FnLogger } from './logger.js'\nimport type { SpanLike } from './otel.js'\n\nexport type MaybePromise<T> = T | Promise<T>\n\n/**\n * An oRPC builder without input or output schema: `os`, `os.$context<T>()`,\n * `os.use(...)`. A schema set on the builder is rejected by `createFn`; set it\n * on the route instead.\n */\n/* biome-ignore-start lint/suspicious/noExplicitAny: matches every builder's generic methods */\nexport type BuilderLike = {\n\troute(route: any): unknown\n\tmeta(meta: any): unknown\n\tinput(schema: any): unknown\n\toutput(schema: any): unknown\n\thandler(handler: any): Procedure<any, any, any, any, any, any>\n}\n/* biome-ignore-end lint/suspicious/noExplicitAny: matches every builder's generic methods */\n\n/** Input a procedure is called with (before its input schema runs). */\nexport type ProcedureInput<T> =\n\tT extends Procedure<\n\t\tinfer _TInitial,\n\t\tinfer _TCurrent,\n\t\tinfer TInputSchema extends AnySchema,\n\t\tinfer _TOut,\n\t\tinfer _TErrors,\n\t\tinfer _TMeta\n\t>\n\t\t? InferSchemaInput<TInputSchema>\n\t\t: unknown\n\n/** What a procedure resolves to (after its output schema runs). */\nexport type ProcedureOutput<T> =\n\tT extends Procedure<\n\t\tinfer _TInitial,\n\t\tinfer _TCurrent,\n\t\tinfer _TIn,\n\t\tinfer TOutputSchema extends AnySchema,\n\t\tinfer _TErrors,\n\t\tinfer _TMeta\n\t>\n\t\t? InferSchemaOutput<TOutputSchema>\n\t\t: unknown\n\n/** Context a procedure must be called with. */\nexport type ProcedureContext<T> =\n\tT extends Procedure<\n\t\tinfer TContext,\n\t\tinfer _TCurrent,\n\t\tinfer _TIn,\n\t\tinfer _TOut,\n\t\tinfer _TErrors,\n\t\tinfer _TMeta\n\t>\n\t\t? TContext\n\t\t: never\n\n/** `Omit` that keeps each member of a union (handler params narrow by discriminant). */\nexport type DistributiveOmit<T, K extends PropertyKey> = T extends unknown\n\t? Omit<T, K>\n\t: never\n\n/** `fn()` options passed to oRPC's `.route()`; `RouteConfig` is derived from it. */\nexport const ROUTE_OPTION_KEYS = [\n\t'path',\n\t'method',\n\t'summary',\n\t'description',\n\t'deprecated',\n\t'successStatus',\n\t'successDescription',\n\t'inputStructure',\n\t'outputStructure',\n\t'tags'\n] as const satisfies readonly (keyof Route)[]\n\n/**\n * `fn()` option names owned by the route itself. Guard keys must not\n * reuse them: such an option would be read as the route option and the guard\n * would never run.\n */\nexport const RESERVED_OPTION_KEYS = [\n\t...ROUTE_OPTION_KEYS,\n\t'name',\n\t'procedure',\n\t'input',\n\t'output',\n\t'handler',\n\t'live',\n\t'operationId',\n\t'meta',\n\t'stream',\n\t'errors',\n\t'guardResolvers'\n] as const\n\nexport type ReservedOptionKey = (typeof RESERVED_OPTION_KEYS)[number]\n\n/** @internal Builds one route from a selected native procedure builder. */\nexport type BuildProcedure = (options: {\n\tname: string\n\tprocedure: string | undefined\n\troute: Record<string, unknown>\n\tmeta: Record<string, unknown>\n\tinput?: AnySchema | undefined\n\toutput?: AnySchema | undefined\n\tstream?: boolean\n\terrors?: ErrorMap\n\thandler: (options: {\n\t\tinput: unknown\n\t\tcontext: Record<string | symbol, unknown>\n\t\tsignal?: AbortSignal\n\t\tlastEventId?: string\n\t\terrors: ReturnType<typeof createORPCErrorConstructorMap>\n\t}) => unknown\n}) => AnyProcedure\n\n/** Turns every key of `T` found in `K` into a readable type error. */\nexport type RejectKeys<T, K extends PropertyKey, TMessage extends string> = {\n\t[P in Extract<keyof T, K>]: TMessage\n}\n\n/**\n * Handler extras must have known keys: an index signature would claim every\n * handler param. Intersected into `createFn`'s options to reject it.\n */\nexport type FiniteExtras<T> = T extends unknown\n\t? string extends keyof T\n\t\t? { extras: 'orpc-fn: extras need known keys, not an index signature' }\n\t\t: number extends keyof T\n\t\t\t? { extras: 'orpc-fn: extras need known keys, not an index signature' }\n\t\t\t: Extract<\n\t\t\t\t\t\tkeyof T,\n\t\t\t\t\t\t| 'input'\n\t\t\t\t\t\t| 'context'\n\t\t\t\t\t\t| 'call'\n\t\t\t\t\t\t| 'signal'\n\t\t\t\t\t\t| 'span'\n\t\t\t\t\t\t| 'logger'\n\t\t\t\t\t\t| 'errors'\n\t\t\t\t\t\t| 'lastEventId'\n\t\t\t\t\t> extends never\n\t\t\t\t? unknown\n\t\t\t\t: { extras: 'orpc-fn: extras cannot shadow handler parameters' }\n\t: never\n\ntype ProcedureOf<TBuilder> = TBuilder extends {\n\thandler(handler: never): infer TProcedure\n}\n\t? TProcedure\n\t: never\n\n/** Context a route built from this builder is called with. */\nexport type InitialContextOf<TBuilder> = ProcedureContext<ProcedureOf<TBuilder>>\n\n/** Context the handler sees, after the builder's middleware. */\nexport type CurrentContextOf<TBuilder> =\n\tProcedureOf<TBuilder> extends Procedure<\n\t\tinfer _TInitial,\n\t\tinfer TContext,\n\t\tinfer _TIn,\n\t\tinfer _TOut,\n\t\tinfer _TErrors,\n\t\tinfer _TMeta\n\t>\n\t\t? TContext\n\t\t: never\n\nexport type ErrorMapOf<TBuilder> = NativeErrors<ProcedureOf<TBuilder>>\ntype MetaOf<TBuilder> = NativeMeta<ProcedureOf<TBuilder>>\n\n/**\n * Everything `createFn` inferred from its options. Route types read from it;\n * apps rarely spell it out.\n */\nexport type FnDefinition = {\n\tprocedures: Record<string, BuilderLike>\n\tdefault: string\n\textras: object\n\textrasByProcedure?: Partial<Record<string, object>>\n\tguards: object\n\tmeta: object\n\ttag: string\n\tspan: SpanLike\n\tlogger: FnLogger\n}\n\nexport type ProcedureKey<TDef extends FnDefinition> = keyof TDef['procedures'] &\n\tstring\n\n/** Context the handler of a `procedure: TKey` route receives. */\nexport type FnContext<\n\tTDef extends FnDefinition,\n\tTKey extends ProcedureKey<TDef>\n> = CurrentContextOf<TDef['procedures'][TKey]>\n\n/** Union of every procedure's handler context: what guards and extras see. */\nexport type AnyFnContext<TDef extends FnDefinition> = {\n\t[K in ProcedureKey<TDef>]: FnContext<TDef, K>\n}[ProcedureKey<TDef>]\n\nexport type GuardParams<TContext, TMeta> = {\n\tcontext: TContext\n\tinput: unknown\n\t/** Route name (operationId). */\n\tname: string\n\t/** Procedures key the route was built from. */\n\tprocedure: string\n\tmeta: Partial<TMeta>\n\tsignal: AbortSignal | undefined\n}\n\n/**\n * A check run before the handler. Its first parameter becomes an option on\n * `fn({...})`; the guard runs only on routes that set it. Throw (usually an\n * `ORPCError`) to refuse the call.\n */\n/* biome-ignore-start lint/suspicious/noConfusingVoidType: union prevents accidental value returns while accepting assertion-style guards */\nexport type Guard<TValue, TParams> = (\n\tvalue: TValue,\n\tparams: TParams\n) => MaybePromise<void | boolean>\n/* biome-ignore-end lint/suspicious/noConfusingVoidType: assertion-style guards */\n\nexport type GuardOptions<TGuards> = {\n\t[K in keyof TGuards]?: TGuards[K] extends (\n\t\tvalue: infer TValue,\n\t\tparams: never\n\t) => unknown\n\t\t? TValue\n\t\t: never\n}\n\n/** Match object spread: scoped extras replace shared keys, preserving unions. */\ntype MergeExtras<TShared, TScoped> = TShared extends unknown\n\t? TScoped extends unknown\n\t\t? Omit<TShared, keyof TScoped> & TScoped\n\t\t: never\n\t: never\n\nexport type HandlerParams<\n\tTDef extends FnDefinition,\n\tTInput,\n\tTKey extends ProcedureKey<TDef>,\n\tTErrors extends ErrorMap = Record<never, never>\n> = DistributiveOmit<\n\tMergeExtras<\n\t\tTDef['extras'],\n\t\tTDef extends { extrasByProcedure: infer E }\n\t\t\t? TKey extends keyof E\n\t\t\t\t? E[TKey]\n\t\t\t\t: object\n\t\t\t: object\n\t>,\n\t| 'input'\n\t| 'context'\n\t| 'call'\n\t| 'signal'\n\t| 'span'\n\t| 'logger'\n\t| 'errors'\n\t| 'lastEventId'\n> & {\n\tinput: TInput\n\tcontext: FnContext<TDef, TKey>\n\t/** Calls another procedure with this context and signal, in a child span. */\n\tcall: BoundCall<FnContext<TDef, TKey>>\n\t/** Cancellation is inherited by nested calls; pass to interruptible I/O. */\n\tsignal: AbortSignal | undefined\n\t/** Active OpenTelemetry span, undefined when `createFn({ otel })` is not set. */\n\tspan: TDef['span'] | undefined\n\tlogger: TDef['logger']\n\tlastEventId: string | undefined\n\terrors: ReturnType<\n\t\ttypeof createORPCErrorConstructorMap<\n\t\t\tMergedErrorMap<ErrorMapOf<TDef['procedures'][TKey]>, TErrors>\n\t\t>\n\t>\n}\n\n/** Route options shared by every `fn()` overload. */\nexport type RouteConfig<TTag extends string = string> = Pick<\n\tRoute,\n\tExclude<(typeof ROUTE_OPTION_KEYS)[number], 'tags'>\n> & {\n\t/** Required. Becomes the OpenAPI operationId and the span name (e.g. 'user.create'). */\n\tname: string\n\ttags?: TTag[]\n}\n\nexport type FnRouteOptions<\n\tTDef extends FnDefinition,\n\tTKey extends ProcedureKey<TDef>,\n\tTInput = unknown,\n\tTErrors extends ErrorMap = Record<never, never>\n> = RouteConfig<TDef['tag']> &\n\tGuardOptions<TDef['guards']> & {\n\t\tmeta?: TDef['meta']\n\t\tstream?: boolean\n\t\terrors?: TErrors\n\t\tguardResolvers?: {\n\t\t\t[K in keyof TDef['guards']]?: (params: {\n\t\t\t\tinput: TInput\n\t\t\t\tcontext: FnContext<TDef, TKey>\n\t\t\t\tsignal: AbortSignal | undefined\n\t\t\t}) => MaybePromise<GuardOptions<TDef['guards']>[K]>\n\t\t}\n\t} & ProcedureOption<TDef, TKey>\n\n/**\n * Which `createFn({ procedures })` builder a route uses. Optional when\n * `createFn` has a `default`; required on every route when it has none.\n */\nexport type ProcedureOption<\n\tTDef extends FnDefinition,\n\tTKey extends ProcedureKey<TDef>\n> = [TDef['default']] extends [never]\n\t? { procedure: TKey }\n\t: { procedure?: TKey }\n\nexport type FnProcedure<\n\tTDef extends FnDefinition,\n\tTKey extends ProcedureKey<TDef>,\n\tTInputSchema extends Schema<unknown, unknown>,\n\tTOutputSchema extends Schema<unknown, unknown>,\n\tTErrors extends ErrorMap = Record<never, never>\n> = DecoratedProcedure<\n\tInitialContextOf<TDef['procedures'][TKey]>,\n\tFnContext<TDef, TKey>,\n\tTInputSchema,\n\tTOutputSchema,\n\tMergedErrorMap<ErrorMapOf<TDef['procedures'][TKey]>, TErrors>,\n\tMetaOf<TDef['procedures'][TKey]> & {\n\t\t'orpc-fn': StoredFnMeta<TDef['meta'], TKey>\n\t}\n>\n\ntype InputOf<T> = [T] extends [AnySchema] ? InferSchemaOutput<T> : unknown\ntype ReturnOf<TOut, TReturn> = [TOut] extends [AnySchema]\n\t? InferSchemaInput<TOut>\n\t: TReturn\n\n/** `fn()`: four overloads for input/output schema × inferred. */\nexport interface Fn<TDef extends FnDefinition> {\n\t// 1. With input + output schema\n\t<\n\t\tTInput extends AnySchema,\n\t\tTOut extends AnySchema,\n\t\tTKey extends ProcedureKey<TDef> = TDef['default'],\n\t\tTErrors extends ErrorMap = Record<never, never>\n\t>(\n\t\toptions: {\n\t\t\tinput: TInput\n\t\t\toutput: TOut\n\t\t\t// The output schema parses what the handler returns: its input type.\n\t\t\thandler: (\n\t\t\t\tparams: HandlerParams<\n\t\t\t\t\tTDef,\n\t\t\t\t\tInferSchemaOutput<TInput>,\n\t\t\t\t\tNoInfer<TKey>,\n\t\t\t\t\tTErrors\n\t\t\t\t>\n\t\t\t) => MaybePromise<InferSchemaInput<TOut>>\n\t\t} & FnRouteOptions<TDef, TKey, InferSchemaOutput<TInput>, TErrors>\n\t): FnProcedure<TDef, TKey, TInput, TOut, TErrors>\n\n\t// 2. With input, inferred output\n\t<\n\t\tTInput extends AnySchema,\n\t\tTReturn,\n\t\tTKey extends ProcedureKey<TDef> = TDef['default'],\n\t\tTErrors extends ErrorMap = Record<never, never>\n\t>(\n\t\toptions: {\n\t\t\tinput: TInput\n\t\t\toutput?: undefined\n\t\t\thandler: (\n\t\t\t\tparams: HandlerParams<\n\t\t\t\t\tTDef,\n\t\t\t\t\tInferSchemaOutput<TInput>,\n\t\t\t\t\tNoInfer<TKey>,\n\t\t\t\t\tTErrors\n\t\t\t\t>\n\t\t\t) => MaybePromise<TReturn>\n\t\t} & FnRouteOptions<TDef, TKey, InferSchemaOutput<TInput>, TErrors>\n\t): FnProcedure<TDef, TKey, TInput, Schema<TReturn, TReturn>, TErrors>\n\n\t// 3. No input, with output schema\n\t<\n\t\tTOut extends AnySchema,\n\t\tTKey extends ProcedureKey<TDef> = TDef['default'],\n\t\tTErrors extends ErrorMap = Record<never, never>\n\t>(\n\t\toptions: {\n\t\t\tinput?: undefined\n\t\t\toutput: TOut\n\t\t\thandler: (\n\t\t\t\tparams: HandlerParams<TDef, unknown, NoInfer<TKey>, TErrors>\n\t\t\t) => MaybePromise<InferSchemaInput<TOut>>\n\t\t} & FnRouteOptions<TDef, TKey, unknown, TErrors>\n\t): FnProcedure<TDef, TKey, Schema<unknown, unknown>, TOut, TErrors>\n\n\t// 4. No input, inferred output\n\t<\n\t\tTReturn,\n\t\tTKey extends ProcedureKey<TDef> = TDef['default'],\n\t\tTErrors extends ErrorMap = Record<never, never>\n\t>(\n\t\toptions: {\n\t\t\tinput?: undefined\n\t\t\toutput?: undefined\n\t\t\thandler: (\n\t\t\t\tparams: HandlerParams<TDef, unknown, NoInfer<TKey>, TErrors>\n\t\t\t) => MaybePromise<TReturn>\n\t\t} & FnRouteOptions<TDef, TKey, unknown, TErrors>\n\t): FnProcedure<\n\t\tTDef,\n\t\tTKey,\n\t\tSchema<unknown, unknown>,\n\t\tSchema<TReturn, TReturn>,\n\t\tTErrors\n\t>\n\n\t// 5. Never matches valid code first; it only words the type errors, which\n\t// TypeScript reports against the last overload.\n\t<\n\t\tTReturn,\n\t\tTInput extends AnySchema | undefined = undefined,\n\t\tTOut extends AnySchema | undefined = undefined,\n\t\tTKey extends ProcedureKey<TDef> = TDef['default'],\n\t\tTErrors extends ErrorMap = Record<never, never>\n\t>(\n\t\toptions: {\n\t\t\tinput?: TInput\n\t\t\toutput?: TOut\n\t\t\t// The output schema parses what the handler returns: its input type.\n\t\t\thandler: (\n\t\t\t\tparams: HandlerParams<TDef, InputOf<TInput>, NoInfer<TKey>, TErrors>\n\t\t\t) => MaybePromise<ReturnOf<TOut, TReturn>>\n\t\t} & FnRouteOptions<TDef, TKey, InputOf<TInput>, TErrors>\n\t): FnProcedure<\n\t\tTDef,\n\t\tTKey,\n\t\t[TInput] extends [AnySchema] ? TInput : Schema<unknown, unknown>,\n\t\t[TOut] extends [AnySchema] ? TOut : Schema<TReturn, TReturn>,\n\t\tTErrors\n\t>\n}\n\n/** What `fn.completed` reports, and what `onCompleted` receives. */\nexport type FnCompletedEvent<TContext = unknown, TSpan = SpanLike> = {\n\tname: string\n\tprocedure: string\n\tdurationMs: number\n\tsuccess: boolean\n\t/** False when authentication or input validation prevented handler execution. */\n\thandlerStarted: boolean\n\terror: unknown\n\tinput: unknown\n\tcontext: TContext\n\tspan: TSpan | undefined\n\tmeta: Record<string, unknown>\n}\n\n/** Factory hooks retain the builder key/context relationship. */\nexport type ProcedureHookParams<\n\tTProcedures extends Record<string, BuilderLike>,\n\tTExtra = object\n> = {\n\t[K in keyof TProcedures & string]: TExtra & {\n\t\tprocedure: K\n\t\tcontext: CurrentContextOf<TProcedures[K]>\n\t}\n}[keyof TProcedures & string]\n\nexport type CompletedHookEvent<\n\tTProcedures extends Record<string, BuilderLike>,\n\tTSpan\n> = {\n\t[K in keyof TProcedures & string]: Omit<\n\t\tFnCompletedEvent<unknown, TSpan>,\n\t\t'context' | 'procedure' | 'handlerStarted'\n\t> & { procedure: K } & (\n\t\t\t| { handlerStarted: true; context: CurrentContextOf<TProcedures[K]> }\n\t\t\t| { handlerStarted: false; context: InitialContextOf<TProcedures[K]> }\n\t\t)\n}[keyof TProcedures & string]\n\nexport type FiniteScopedExtras<T> = {\n\t[K in keyof T]: string extends keyof T[K]\n\t\t? K\n\t\t: number extends keyof T[K]\n\t\t\t? K\n\t\t\t: Extract<\n\t\t\t\t\t\tkeyof T[K],\n\t\t\t\t\t\t| 'input'\n\t\t\t\t\t\t| 'context'\n\t\t\t\t\t\t| 'call'\n\t\t\t\t\t\t| 'signal'\n\t\t\t\t\t\t| 'span'\n\t\t\t\t\t\t| 'logger'\n\t\t\t\t\t\t| 'errors'\n\t\t\t\t\t\t| 'lastEventId'\n\t\t\t\t\t> extends never\n\t\t\t\t? never\n\t\t\t\t: K\n}[keyof T] extends never\n\t? unknown\n\t: {\n\t\t\textrasByProcedure: 'orpc-fn: scoped extras need finite keys and cannot shadow handler parameters'\n\t\t}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAkFA,oFAAoF;AACpF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC,MAAM;IACN,QAAQ;IACR,SAAS;IACT,aAAa;IACb,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB,gBAAgB;IAChB,iBAAiB;IACjB,MAAM;CACsC,CAAA;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IACnC,GAAG,iBAAiB;IACpB,MAAM;IACN,WAAW;IACX,OAAO;IACP,QAAQ;IACR,SAAS;IACT,MAAM;IACN,aAAa;IACb,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,gBAAgB;CACP,CAAA","sourcesContent":["import type {\n\tAnySchema,\n\tErrorMap,\n\tInferSchemaInput,\n\tInferSchemaOutput,\n\tMergedErrorMap,\n\tSchema\n} from '@orpc/contract'\nimport type {\n\tAnyProcedure,\n\tDecoratedProcedure,\n\tProcedure,\n\tRoute\n} from '@orpc/server'\nimport type { createORPCErrorConstructorMap } from '@orpc/server'\nimport type { StoredFnMeta } from './meta.js'\nimport type { NativeErrors, NativeMeta } from './compatibility.js'\nimport type { BoundCall } from './bound-call.js'\nimport type { FnLogger } from './logger.js'\nimport type { SpanLike } from './otel.js'\n\nexport type MaybePromise<T> = T | Promise<T>\n\n/**\n * An oRPC builder without input or output schema: `os`, `os.$context<T>()`,\n * `os.use(...)`. A schema set on the builder is rejected by `createFn`; set it\n * on the route instead.\n */\n/* biome-ignore-start lint/suspicious/noExplicitAny: matches every builder's generic methods */\nexport type BuilderLike = {\n\troute(route: any): unknown\n\tmeta(meta: any): unknown\n\tinput(schema: any): unknown\n\toutput(schema: any): unknown\n\thandler(handler: any): Procedure<any, any, any, any, any, any>\n}\n/* biome-ignore-end lint/suspicious/noExplicitAny: matches every builder's generic methods */\n\n/** Input a procedure is called with (before its input schema runs). */\nexport type ProcedureInput<T> =\n\tT extends Procedure<\n\t\tinfer _TInitial,\n\t\tinfer _TCurrent,\n\t\tinfer TInputSchema extends AnySchema,\n\t\tinfer _TOut,\n\t\tinfer _TErrors,\n\t\tinfer _TMeta\n\t>\n\t\t? InferSchemaInput<TInputSchema>\n\t\t: unknown\n\n/** What a procedure resolves to (after its output schema runs). */\nexport type ProcedureOutput<T> =\n\tT extends Procedure<\n\t\tinfer _TInitial,\n\t\tinfer _TCurrent,\n\t\tinfer _TIn,\n\t\tinfer TOutputSchema extends AnySchema,\n\t\tinfer _TErrors,\n\t\tinfer _TMeta\n\t>\n\t\t? InferSchemaOutput<TOutputSchema>\n\t\t: unknown\n\n/** Context a procedure must be called with. */\nexport type ProcedureContext<T> =\n\tT extends Procedure<\n\t\tinfer TContext,\n\t\tinfer _TCurrent,\n\t\tinfer _TIn,\n\t\tinfer _TOut,\n\t\tinfer _TErrors,\n\t\tinfer _TMeta\n\t>\n\t\t? TContext\n\t\t: never\n\n/** `Omit` that keeps each member of a union (handler params narrow by discriminant). */\nexport type DistributiveOmit<T, K extends PropertyKey> = T extends unknown\n\t? Omit<T, K>\n\t: never\n\n/** `fn()` options passed to oRPC's `.route()`; `RouteConfig` is derived from it. */\nexport const ROUTE_OPTION_KEYS = [\n\t'path',\n\t'method',\n\t'summary',\n\t'description',\n\t'deprecated',\n\t'successStatus',\n\t'successDescription',\n\t'inputStructure',\n\t'outputStructure',\n\t'tags'\n] as const satisfies readonly (keyof Route)[]\n\n/**\n * `fn()` option names owned by the route itself. Guard keys must not\n * reuse them: such an option would be read as the route option and the guard\n * would never run.\n */\nexport const RESERVED_OPTION_KEYS = [\n\t...ROUTE_OPTION_KEYS,\n\t'name',\n\t'procedure',\n\t'input',\n\t'output',\n\t'handler',\n\t'live',\n\t'operationId',\n\t'meta',\n\t'stream',\n\t'errors',\n\t'guardResolvers'\n] as const\n\nexport type ReservedOptionKey = (typeof RESERVED_OPTION_KEYS)[number]\n\n/** @internal Builds one route from a selected native procedure builder. */\nexport type BuildProcedure = (options: {\n\tname: string\n\tprocedure: string | undefined\n\troute: Record<string, unknown>\n\tmeta: Record<string, unknown>\n\tinput?: AnySchema | undefined\n\toutput?: AnySchema | undefined\n\tstream?: boolean\n\terrors?: ErrorMap\n\thandler: (options: {\n\t\tinput: unknown\n\t\tcontext: Record<string | symbol, unknown>\n\t\tsignal?: AbortSignal\n\t\tlastEventId?: string\n\t\terrors: ReturnType<typeof createORPCErrorConstructorMap>\n\t}) => unknown\n}) => AnyProcedure\n\n/** Turns every key of `T` found in `K` into a readable type error. */\nexport type RejectKeys<T, K extends PropertyKey, TMessage extends string> = {\n\t[P in Extract<keyof T, K>]: TMessage\n}\n\n/** Params every handler receives; extras may not reuse these names. */\ntype HandlerParamKey =\n\t| 'input'\n\t| 'context'\n\t| 'call'\n\t| 'signal'\n\t| 'span'\n\t| 'logger'\n\t| 'errors'\n\t| 'lastEventId'\n\n/**\n * Handler extras must have known keys: an index signature would claim every\n * handler param. Intersected into `createFn`'s options to reject it.\n */\nexport type FiniteExtras<T> = T extends unknown\n\t? string extends keyof T\n\t\t? { extras: 'orpc-fn: extras need known keys, not an index signature' }\n\t\t: number extends keyof T\n\t\t\t? { extras: 'orpc-fn: extras need known keys, not an index signature' }\n\t\t\t: Extract<keyof T, HandlerParamKey> extends never\n\t\t\t\t? unknown\n\t\t\t\t: { extras: 'orpc-fn: extras cannot shadow handler parameters' }\n\t: never\n\ntype ProcedureOf<TBuilder> = TBuilder extends {\n\thandler(handler: never): infer TProcedure\n}\n\t? TProcedure\n\t: never\n\n/** Context a route built from this builder is called with. */\nexport type InitialContextOf<TBuilder> = ProcedureContext<ProcedureOf<TBuilder>>\n\n/** Context the handler sees, after the builder's middleware. */\nexport type CurrentContextOf<TBuilder> =\n\tProcedureOf<TBuilder> extends Procedure<\n\t\tinfer _TInitial,\n\t\tinfer TContext,\n\t\tinfer _TIn,\n\t\tinfer _TOut,\n\t\tinfer _TErrors,\n\t\tinfer _TMeta\n\t>\n\t\t? TContext\n\t\t: never\n\nexport type ErrorMapOf<TBuilder> = NativeErrors<ProcedureOf<TBuilder>>\ntype MetaOf<TBuilder> = NativeMeta<ProcedureOf<TBuilder>>\n\n/**\n * Everything `createFn` inferred from its options. Route types read from it;\n * apps rarely spell it out.\n */\nexport type FnDefinition = {\n\tprocedures: Record<string, BuilderLike>\n\tdefault: string\n\textras: object\n\textrasByProcedure?: Partial<Record<string, object>>\n\tguards: object\n\tmeta: object\n\ttag: string\n\tspan: SpanLike\n\tlogger: FnLogger\n}\n\nexport type ProcedureKey<TDef extends FnDefinition> = keyof TDef['procedures'] &\n\tstring\n\n/** Context the handler of a `procedure: TKey` route receives. */\nexport type FnContext<\n\tTDef extends FnDefinition,\n\tTKey extends ProcedureKey<TDef>\n> = CurrentContextOf<TDef['procedures'][TKey]>\n\n/** Union of every procedure's handler context: what guards and extras see. */\nexport type AnyFnContext<TDef extends FnDefinition> = {\n\t[K in ProcedureKey<TDef>]: FnContext<TDef, K>\n}[ProcedureKey<TDef>]\n\nexport type GuardParams<TContext, TMeta> = {\n\tcontext: TContext\n\tinput: unknown\n\t/** Route name (operationId). */\n\tname: string\n\t/** Procedures key the route was built from. */\n\tprocedure: string\n\tmeta: Partial<TMeta>\n\tsignal: AbortSignal | undefined\n}\n\n/**\n * A check run before the handler. Its first parameter becomes an option on\n * `fn({...})`; the guard runs only on routes that set it. Throw (usually an\n * `ORPCError`) to refuse the call.\n */\n/* biome-ignore-start lint/suspicious/noConfusingVoidType: union prevents accidental value returns while accepting assertion-style guards */\nexport type Guard<TValue, TParams> = (\n\tvalue: TValue,\n\tparams: TParams\n) => MaybePromise<void | boolean>\n/* biome-ignore-end lint/suspicious/noConfusingVoidType: assertion-style guards */\n\nexport type GuardOptions<TGuards> = {\n\t[K in keyof TGuards]?: TGuards[K] extends (\n\t\tvalue: infer TValue,\n\t\tparams: never\n\t) => unknown\n\t\t? TValue\n\t\t: never\n}\n\n/** Match object spread: scoped extras replace shared keys, preserving unions. */\ntype MergeExtras<TShared, TScoped> = TShared extends unknown\n\t? TScoped extends unknown\n\t\t? Omit<TShared, keyof TScoped> & TScoped\n\t\t: never\n\t: never\n\nexport type HandlerParams<\n\tTDef extends FnDefinition,\n\tTInput,\n\tTKey extends ProcedureKey<TDef>,\n\tTErrors extends ErrorMap = Record<never, never>\n> = DistributiveOmit<\n\tMergeExtras<\n\t\tTDef['extras'],\n\t\tTDef extends { extrasByProcedure: infer E }\n\t\t\t? TKey extends keyof E\n\t\t\t\t? E[TKey]\n\t\t\t\t: object\n\t\t\t: object\n\t>,\n\tHandlerParamKey\n> & {\n\tinput: TInput\n\tcontext: FnContext<TDef, TKey>\n\t/** Calls another procedure with this context and signal, in a child span. */\n\tcall: BoundCall<FnContext<TDef, TKey>>\n\t/** Cancellation is inherited by nested calls; pass to interruptible I/O. */\n\tsignal: AbortSignal | undefined\n\t/** Active OpenTelemetry span, undefined when `createFn({ otel })` is not set. */\n\tspan: TDef['span'] | undefined\n\tlogger: TDef['logger']\n\tlastEventId: string | undefined\n\terrors: ReturnType<\n\t\ttypeof createORPCErrorConstructorMap<\n\t\t\tMergedErrorMap<ErrorMapOf<TDef['procedures'][TKey]>, TErrors>\n\t\t>\n\t>\n}\n\n/** Route options shared by every `fn()` overload. */\nexport type RouteConfig<TTag extends string = string> = Pick<\n\tRoute,\n\tExclude<(typeof ROUTE_OPTION_KEYS)[number], 'tags'>\n> & {\n\t/** Required. Becomes the OpenAPI operationId and the span name (e.g. 'user.create'). */\n\tname: string\n\ttags?: TTag[]\n}\n\nexport type FnRouteOptions<\n\tTDef extends FnDefinition,\n\tTKey extends ProcedureKey<TDef>,\n\tTInput = unknown,\n\tTErrors extends ErrorMap = Record<never, never>\n> = RouteConfig<TDef['tag']> &\n\tGuardOptions<TDef['guards']> & {\n\t\tmeta?: TDef['meta']\n\t\tstream?: boolean\n\t\terrors?: TErrors\n\t\tguardResolvers?: {\n\t\t\t[K in keyof TDef['guards']]?: (params: {\n\t\t\t\tinput: TInput\n\t\t\t\tcontext: FnContext<TDef, TKey>\n\t\t\t\tsignal: AbortSignal | undefined\n\t\t\t}) => MaybePromise<GuardOptions<TDef['guards']>[K]>\n\t\t}\n\t} & ProcedureOption<TDef, TKey>\n\n/**\n * Which `createFn({ procedures })` builder a route uses. Optional when\n * `createFn` has a `default`; required on every route when it has none.\n */\nexport type ProcedureOption<\n\tTDef extends FnDefinition,\n\tTKey extends ProcedureKey<TDef>\n> = [TDef['default']] extends [never]\n\t? { procedure: TKey }\n\t: { procedure?: TKey }\n\nexport type FnProcedure<\n\tTDef extends FnDefinition,\n\tTKey extends ProcedureKey<TDef>,\n\tTInputSchema extends Schema<unknown, unknown>,\n\tTOutputSchema extends Schema<unknown, unknown>,\n\tTErrors extends ErrorMap = Record<never, never>\n> = DecoratedProcedure<\n\tInitialContextOf<TDef['procedures'][TKey]>,\n\tFnContext<TDef, TKey>,\n\tTInputSchema,\n\tTOutputSchema,\n\tMergedErrorMap<ErrorMapOf<TDef['procedures'][TKey]>, TErrors>,\n\tMetaOf<TDef['procedures'][TKey]> & {\n\t\t'orpc-fn': StoredFnMeta<TDef['meta'], TKey>\n\t}\n>\n\ntype InputOf<T> = [T] extends [AnySchema] ? InferSchemaOutput<T> : unknown\ntype ReturnOf<TOut, TReturn> = [TOut] extends [AnySchema]\n\t? InferSchemaInput<TOut>\n\t: TReturn\n\n/** `fn()`: four overloads for input/output schema × inferred. */\nexport interface Fn<TDef extends FnDefinition> {\n\t// 1. With input + output schema\n\t<\n\t\tTInput extends AnySchema,\n\t\tTOut extends AnySchema,\n\t\tTKey extends ProcedureKey<TDef> = TDef['default'],\n\t\tTErrors extends ErrorMap = Record<never, never>\n\t>(\n\t\toptions: {\n\t\t\tinput: TInput\n\t\t\toutput: TOut\n\t\t\t// The output schema parses what the handler returns: its input type.\n\t\t\thandler: (\n\t\t\t\tparams: HandlerParams<\n\t\t\t\t\tTDef,\n\t\t\t\t\tInferSchemaOutput<TInput>,\n\t\t\t\t\tNoInfer<TKey>,\n\t\t\t\t\tTErrors\n\t\t\t\t>\n\t\t\t) => MaybePromise<InferSchemaInput<TOut>>\n\t\t} & FnRouteOptions<TDef, TKey, InferSchemaOutput<TInput>, TErrors>\n\t): FnProcedure<TDef, TKey, TInput, TOut, TErrors>\n\n\t// 2. With input, inferred output\n\t<\n\t\tTInput extends AnySchema,\n\t\tTReturn,\n\t\tTKey extends ProcedureKey<TDef> = TDef['default'],\n\t\tTErrors extends ErrorMap = Record<never, never>\n\t>(\n\t\toptions: {\n\t\t\tinput: TInput\n\t\t\toutput?: undefined\n\t\t\thandler: (\n\t\t\t\tparams: HandlerParams<\n\t\t\t\t\tTDef,\n\t\t\t\t\tInferSchemaOutput<TInput>,\n\t\t\t\t\tNoInfer<TKey>,\n\t\t\t\t\tTErrors\n\t\t\t\t>\n\t\t\t) => MaybePromise<TReturn>\n\t\t} & FnRouteOptions<TDef, TKey, InferSchemaOutput<TInput>, TErrors>\n\t): FnProcedure<TDef, TKey, TInput, Schema<TReturn, TReturn>, TErrors>\n\n\t// 3. No input, with output schema\n\t<\n\t\tTOut extends AnySchema,\n\t\tTKey extends ProcedureKey<TDef> = TDef['default'],\n\t\tTErrors extends ErrorMap = Record<never, never>\n\t>(\n\t\toptions: {\n\t\t\tinput?: undefined\n\t\t\toutput: TOut\n\t\t\thandler: (\n\t\t\t\tparams: HandlerParams<TDef, unknown, NoInfer<TKey>, TErrors>\n\t\t\t) => MaybePromise<InferSchemaInput<TOut>>\n\t\t} & FnRouteOptions<TDef, TKey, unknown, TErrors>\n\t): FnProcedure<TDef, TKey, Schema<unknown, unknown>, TOut, TErrors>\n\n\t// 4. No input, inferred output\n\t<\n\t\tTReturn,\n\t\tTKey extends ProcedureKey<TDef> = TDef['default'],\n\t\tTErrors extends ErrorMap = Record<never, never>\n\t>(\n\t\toptions: {\n\t\t\tinput?: undefined\n\t\t\toutput?: undefined\n\t\t\thandler: (\n\t\t\t\tparams: HandlerParams<TDef, unknown, NoInfer<TKey>, TErrors>\n\t\t\t) => MaybePromise<TReturn>\n\t\t} & FnRouteOptions<TDef, TKey, unknown, TErrors>\n\t): FnProcedure<\n\t\tTDef,\n\t\tTKey,\n\t\tSchema<unknown, unknown>,\n\t\tSchema<TReturn, TReturn>,\n\t\tTErrors\n\t>\n\n\t// 5. Never matches valid code first; it only words the type errors, which\n\t// TypeScript reports against the last overload.\n\t<\n\t\tTReturn,\n\t\tTInput extends AnySchema | undefined = undefined,\n\t\tTOut extends AnySchema | undefined = undefined,\n\t\tTKey extends ProcedureKey<TDef> = TDef['default'],\n\t\tTErrors extends ErrorMap = Record<never, never>\n\t>(\n\t\toptions: {\n\t\t\tinput?: TInput\n\t\t\toutput?: TOut\n\t\t\t// The output schema parses what the handler returns: its input type.\n\t\t\thandler: (\n\t\t\t\tparams: HandlerParams<TDef, InputOf<TInput>, NoInfer<TKey>, TErrors>\n\t\t\t) => MaybePromise<ReturnOf<TOut, TReturn>>\n\t\t} & FnRouteOptions<TDef, TKey, InputOf<TInput>, TErrors>\n\t): FnProcedure<\n\t\tTDef,\n\t\tTKey,\n\t\t[TInput] extends [AnySchema] ? TInput : Schema<unknown, unknown>,\n\t\t[TOut] extends [AnySchema] ? TOut : Schema<TReturn, TReturn>,\n\t\tTErrors\n\t>\n}\n\n/** What `fn.completed` reports, and what `onCompleted` receives. */\nexport type FnCompletedEvent<TContext = unknown, TSpan = SpanLike> = {\n\tname: string\n\tprocedure: string\n\tdurationMs: number\n\tsuccess: boolean\n\t/** False when authentication or input validation prevented handler execution. */\n\thandlerStarted: boolean\n\terror: unknown\n\tinput: unknown\n\tcontext: TContext\n\tspan: TSpan | undefined\n\tmeta: Record<string, unknown>\n}\n\n/** Factory hooks retain the builder key/context relationship. */\nexport type ProcedureHookParams<\n\tTProcedures extends Record<string, BuilderLike>,\n\tTExtra = object\n> = {\n\t[K in keyof TProcedures & string]: TExtra & {\n\t\tprocedure: K\n\t\tcontext: CurrentContextOf<TProcedures[K]>\n\t}\n}[keyof TProcedures & string]\n\nexport type CompletedHookEvent<\n\tTProcedures extends Record<string, BuilderLike>,\n\tTSpan\n> = {\n\t[K in keyof TProcedures & string]: Omit<\n\t\tFnCompletedEvent<unknown, TSpan>,\n\t\t'context' | 'procedure' | 'handlerStarted'\n\t> & { procedure: K } & (\n\t\t\t| { handlerStarted: true; context: CurrentContextOf<TProcedures[K]> }\n\t\t\t| { handlerStarted: false; context: InitialContextOf<TProcedures[K]> }\n\t\t)\n}[keyof TProcedures & string]\n\n/**\n * Intersected into each scoped extras function's return type: rejects index\n * signatures and handler-parameter names at the offending property. A\n * top-level conditional over the whole map broke inference when zero-argument\n * and context-reading functions were mixed.\n */\nexport type ScopedExtrasGuard<T> = (string extends keyof T\n\t? { 'orpc-fn: scoped extras need finite keys': never }\n\t: number extends keyof T\n\t\t? { 'orpc-fn: scoped extras need finite keys': never }\n\t\t: unknown) & { [K in HandlerParamKey]?: never }\n"]}
|