@farm.js/core 0.1.14 → 0.1.16
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/agent-runtime.d.mts +5 -2
- package/dist/agent-runtime.d.ts +5 -2
- package/dist/api/client.d.mts +3 -2
- package/dist/api/client.d.ts +3 -2
- package/dist/api/route-manager.d.mts +5 -2
- package/dist/api/route-manager.d.ts +5 -2
- package/dist/api/runtime.d.mts +3 -2
- package/dist/api/runtime.d.ts +3 -2
- package/dist/{api-client-C8d7BZNp.d.mts → api-client-B-n3pm_Q.d.mts} +2 -1
- package/dist/{api-client-BWrEbxfO.d.ts → api-client-C0_NZEBl.d.ts} +2 -1
- package/dist/api.d.mts +7 -4
- package/dist/api.d.ts +7 -4
- package/dist/{app-wIYse61b.d.ts → app-AyjEsCBq.d.ts} +3 -3
- package/dist/{app-B3nVSjen.d.mts → app-CYPHeOo_.d.mts} +3 -3
- package/dist/app-markdown.d.mts +6 -3
- package/dist/app-markdown.d.ts +6 -3
- package/dist/{chunk-FOGLGRDS.mjs → chunk-7HDZYYS4.mjs} +100 -8
- package/dist/{chunk-DNCKVMSV.mjs → chunk-IL5RWYK7.mjs} +1 -1
- package/dist/{chunk-GNTPTTLA.mjs → chunk-IXTEENRS.mjs} +1 -1
- package/dist/{chunk-J2F5LFQ2.mjs → chunk-NHHKW2T6.mjs} +175 -8
- package/dist/{chunk-NJ47VORC.mjs → chunk-NUD6XBMO.mjs} +1 -1
- package/dist/{chunk-U6CRU23N.mjs → chunk-TYVVIQ5M.mjs} +10 -7
- package/dist/{chunk-W7IVHTOP.mjs → chunk-UQZPTIML.mjs} +15 -2
- package/dist/{chunk-S3QW3BIS.mjs → chunk-VVTREAG5.mjs} +89 -4
- package/dist/{client-plugins-C1EgdoJM.d.mts → client-plugins-CIPRtSsW.d.mts} +16 -4
- package/dist/{client-plugins-CslwYp3E.d.ts → client-plugins-CqVtZi5X.d.ts} +16 -4
- package/dist/client-plugins.d.mts +5 -2
- package/dist/client-plugins.d.ts +5 -2
- package/dist/client.d.mts +8 -7
- package/dist/client.d.ts +8 -7
- package/dist/config.d.mts +5 -2
- package/dist/config.d.ts +5 -2
- package/dist/{devtools-PCGEBRSC.mjs → devtools-IU7LKZOH.mjs} +2 -2
- package/dist/docs.cjs +74 -3
- package/dist/docs.mjs +3 -3
- package/dist/{route-C6UClI1z.d.mts → endpoint-Bu3XgeMK.d.mts} +3 -128
- package/dist/{route-CHBaW55F.d.ts → endpoint-kSAxE52R.d.ts} +3 -128
- package/dist/env.cjs +101 -8
- package/dist/env.d.mts +20 -2
- package/dist/env.d.ts +20 -2
- package/dist/env.mjs +3 -1
- package/dist/index.cjs +383 -24
- package/dist/index.d.mts +16 -15
- package/dist/index.d.ts +16 -15
- package/dist/index.mjs +20 -8
- package/dist/integrations.d.mts +5 -2
- package/dist/integrations.d.ts +5 -2
- package/dist/internal/app-markdown-runtime.d.mts +5 -2
- package/dist/internal/app-markdown-runtime.d.ts +5 -2
- package/dist/internal/build-runtime.cjs +435 -174
- package/dist/internal/build-runtime.d.mts +7 -4
- package/dist/internal/build-runtime.d.ts +7 -4
- package/dist/internal/build-runtime.mjs +6 -6
- package/dist/internal/cli-runtime.cjs +68 -4
- package/dist/internal/cli-runtime.mjs +2 -2
- package/dist/internal/client-error-overlay.cjs +1 -1
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +5 -2
- package/dist/internal/compression-runtime.d.ts +5 -2
- package/dist/internal/config-runtime.cjs +68 -4
- package/dist/internal/config-runtime.d.mts +6 -3
- package/dist/internal/config-runtime.d.ts +6 -3
- package/dist/internal/config-runtime.mjs +2 -2
- package/dist/internal/product-telemetry-runtime.cjs +1 -1
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.d.mts +11 -8
- package/dist/internal/production-runtime.d.ts +11 -8
- package/dist/{metadata-BsUcOEXg.d.ts → metadata-8g__AMPM.d.ts} +1 -1
- package/dist/{metadata-B1bxCPUY.d.mts → metadata-OMX6wFNf.d.mts} +1 -1
- package/dist/middleware.d.mts +7 -4
- package/dist/middleware.d.ts +7 -4
- package/dist/{nitro-ICBP5APY.mjs → nitro-3N4ZXRYM.mjs} +5 -2
- package/dist/plugin.cjs +278 -11
- package/dist/plugin.d.mts +5 -2
- package/dist/plugin.d.ts +5 -2
- package/dist/plugin.mjs +3 -3
- package/dist/{production-runtime-CsNn2-zx.d.ts → production-runtime-BJh7o6Cr.d.ts} +1 -1
- package/dist/{production-runtime-BDllolVh.d.mts → production-runtime-W3M0eNDV.d.mts} +1 -1
- package/dist/{render-plan-EG4hNFjy.d.ts → render-plan-Be4ZGTJP.d.ts} +1 -1
- package/dist/{render-plan-CNUlzylR.d.mts → render-plan-io7pvDNc.d.mts} +1 -1
- package/dist/renderer-client.d.mts +5 -4
- package/dist/renderer-client.d.ts +5 -4
- package/dist/{request-Blh_f7Z3.d.mts → request-DZkHYQ89.d.mts} +1 -1
- package/dist/{request-DsVSQVfD.d.ts → request-G8JhKr4F.d.ts} +1 -1
- package/dist/request.d.mts +6 -3
- package/dist/request.d.ts +6 -3
- package/dist/route-BxNJT447.d.ts +128 -0
- package/dist/route-C_eLaFTZ.d.mts +128 -0
- package/dist/{route-rendering-hUETRCbM.d.ts → route-rendering-BcLLPJgN.d.ts} +1 -1
- package/dist/{route-rendering-LT4XSoQK.d.mts → route-rendering-CbAKr1TY.d.mts} +1 -1
- package/dist/routes.d.mts +4 -2
- package/dist/routes.d.ts +4 -2
- package/dist/server-fn-client.d.mts +3 -2
- package/dist/server-fn-client.d.ts +3 -2
- package/dist/server-fn.cjs +141 -3
- package/dist/server-fn.d.mts +72 -1
- package/dist/server-fn.d.ts +72 -1
- package/dist/server-fn.mjs +12 -1
- package/dist/server-plugins.d.mts +6 -3
- package/dist/server-plugins.d.ts +6 -3
- package/dist/server-query-client.d.mts +1 -0
- package/dist/server-query-client.d.ts +1 -0
- package/dist/server-query.cjs +60 -3
- package/dist/server-query.d.mts +6 -1
- package/dist/server-query.d.ts +6 -1
- package/dist/server-query.mjs +3 -2
- package/dist/server.cjs +331 -15
- package/dist/server.d.mts +9 -8
- package/dist/server.d.ts +9 -8
- package/dist/server.mjs +6 -6
- package/dist/{spa-router-csKR9Ebj.d.mts → spa-router-BcS_4nqm.d.mts} +2 -2
- package/dist/{spa-router-Y_2FSJQK.d.ts → spa-router-BzFBUJkn.d.ts} +2 -2
- package/dist/testing.d.mts +5 -3
- package/dist/testing.d.ts +5 -3
- package/dist/{utils-DR2wfZAn.d.mts → utils-5kQP1mFR.d.mts} +1 -1
- package/dist/{utils-jISOE9SD.d.ts → utils-C4yrAhNc.d.ts} +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +416 -153
- package/dist/vite.d.mts +5 -2
- package/dist/vite.d.ts +5 -2
- package/dist/vite.mjs +3 -3
- package/package.json +3 -3
package/dist/server-fn.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FarmCacheInvalidationTarget } from './cache.mjs';
|
|
2
2
|
import { S as ServerFnFailure, a as ServerActionError } from './server-fn-error-DDh14a0V.mjs';
|
|
3
3
|
export { F as FARM_SERVER_FN_FAILURE_SYMBOL, b as SerializedServerFnFailure, c as createServerFnTransportError, i as isServerFnFailure } from './server-fn-error-DDh14a0V.mjs';
|
|
4
|
+
import { d as EndpointMCPMetadata } from './endpoint-Bu3XgeMK.mjs';
|
|
4
5
|
|
|
5
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
7
|
type ServerFnSchema = {
|
|
@@ -38,6 +39,10 @@ type ServerFnDeclaredError<TErrors extends ServerFnErrorDefinitions> = {
|
|
|
38
39
|
type ServerFnError<TErrors extends ServerFnErrorDefinitions> = keyof TErrors extends never ? Error : ServerActionError | ServerFnDeclaredError<TErrors>;
|
|
39
40
|
type ServerFnErrorHandler<TErrors extends ServerFnErrorDefinitions> = <TCode extends keyof TErrors & string>(code: TCode, data: InferServerFnSchemaInput<TErrors[TCode]["data"]>) => never;
|
|
40
41
|
type ServerFnFormInput = FormData;
|
|
42
|
+
/** MCP tool metadata for a server function or query. Server functions have no path to derive a name from. */
|
|
43
|
+
type ServerFnMCPMetadata = EndpointMCPMetadata & {
|
|
44
|
+
name: string;
|
|
45
|
+
};
|
|
41
46
|
type Simplify<T> = {
|
|
42
47
|
[TKey in keyof T]: T[TKey];
|
|
43
48
|
} & {};
|
|
@@ -92,6 +97,8 @@ type ServerFnOptions<TSchema extends ServerFnSchema | undefined, TResult, TMiddl
|
|
|
92
97
|
output?: undefined;
|
|
93
98
|
middleware?: TMiddlewares;
|
|
94
99
|
errors?: TErrors;
|
|
100
|
+
/** Expose this function as an MCP tool when it is listed in `mcp.tools`. `name` is required. */
|
|
101
|
+
mcp?: ServerFnMCPMetadata;
|
|
95
102
|
invalidates?: ServerFnInvalidations<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, Awaited<TResult>, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
96
103
|
handler: ServerFnHandler<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, TResult, ServerFnMiddlewareContext<TMiddlewares>, TErrors>;
|
|
97
104
|
};
|
|
@@ -100,6 +107,8 @@ type ServerFnOutputOptions<TInputSchema extends ServerFnSchema | undefined, TOut
|
|
|
100
107
|
output: TOutputSchema;
|
|
101
108
|
middleware?: TMiddlewares;
|
|
102
109
|
errors?: TErrors;
|
|
110
|
+
/** Expose this function as an MCP tool when it is listed in `mcp.tools`. `name` is required. */
|
|
111
|
+
mcp?: ServerFnMCPMetadata;
|
|
103
112
|
invalidates?: ServerFnInvalidations<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, Awaited<InferServerFnSchemaOutput<TOutputSchema>>, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
104
113
|
handler: ServerFnHandler<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, unknown, ServerFnMiddlewareContext<TMiddlewares>, TErrors>;
|
|
105
114
|
};
|
|
@@ -111,6 +120,68 @@ type ServerFn<TInput, TResult, TError extends Error = Error> = ([unknown] extend
|
|
|
111
120
|
};
|
|
112
121
|
type InferServerFnError<TServerFn> = TServerFn extends ServerFn<any, any, infer TError> ? TError : Error;
|
|
113
122
|
declare const FARM_SERVER_FN_SYMBOL: unique symbol;
|
|
123
|
+
/** @internal What a non-browser caller, such as an MCP tool, needs to know about a server function. */
|
|
124
|
+
interface ServerFunctionDescriptor {
|
|
125
|
+
/** Queries only read data; actions may change it. */
|
|
126
|
+
readonly kind: "action" | "query";
|
|
127
|
+
readonly input: ServerFnSchema | undefined;
|
|
128
|
+
readonly output: ServerFnSchema | undefined;
|
|
129
|
+
readonly mcp: Readonly<ServerFnMCPMetadata> | undefined;
|
|
130
|
+
}
|
|
131
|
+
interface ServerFunctionRunner extends ServerFunctionDescriptor {
|
|
132
|
+
/** Runs the full pipeline and labels input validation failures with ServerFnInputError. */
|
|
133
|
+
readonly run: (input: unknown) => Promise<unknown>;
|
|
134
|
+
}
|
|
135
|
+
/** @internal Shared by createServerFn and createServerQuery. */
|
|
136
|
+
declare function createServerFunctionDescriptor(kind: ServerFunctionDescriptor["kind"], options: {
|
|
137
|
+
input?: ServerFnSchema;
|
|
138
|
+
output?: ServerFnSchema;
|
|
139
|
+
mcp?: ServerFnMCPMetadata;
|
|
140
|
+
}, run: ServerFunctionRunner["run"]): ServerFunctionRunner;
|
|
141
|
+
/** @internal Attaches the descriptor that `_describeServerFunction` reads. */
|
|
142
|
+
declare function _attachServerFunctionDescriptor(target: object, descriptor: ServerFunctionRunner): void;
|
|
143
|
+
/** @internal Runs a server function's pipeline with input failures labelled, for createServerQuery. */
|
|
144
|
+
declare function _runServerFunctionForCaller(value: unknown, input: unknown): Promise<unknown>;
|
|
145
|
+
/**
|
|
146
|
+
* @internal Describes a createServerFn or createServerQuery function, or returns undefined for
|
|
147
|
+
* anything else. Exposes schemas and metadata, never the handler.
|
|
148
|
+
*/
|
|
149
|
+
declare function _describeServerFunction(value: unknown): ServerFunctionDescriptor | undefined;
|
|
150
|
+
/** @internal How a server function call ended, for callers that are not the browser action transport. */
|
|
151
|
+
type ServerFunctionInvocation = {
|
|
152
|
+
readonly ok: true;
|
|
153
|
+
readonly data: unknown;
|
|
154
|
+
}
|
|
155
|
+
/** The caller's input failed the input schema. The validator's error describes the caller's own data. */
|
|
156
|
+
| {
|
|
157
|
+
readonly ok: false;
|
|
158
|
+
readonly reason: "input";
|
|
159
|
+
readonly error: unknown;
|
|
160
|
+
}
|
|
161
|
+
/** A failure declared in `errors`, public by design. */
|
|
162
|
+
| {
|
|
163
|
+
readonly ok: false;
|
|
164
|
+
readonly reason: "failure";
|
|
165
|
+
readonly failure: ServerFnFailure;
|
|
166
|
+
} | {
|
|
167
|
+
readonly ok: false;
|
|
168
|
+
readonly reason: "redirect";
|
|
169
|
+
readonly url: string;
|
|
170
|
+
readonly status: number;
|
|
171
|
+
}
|
|
172
|
+
/** Anything else. Can contain private data, so callers must not expose it. */
|
|
173
|
+
| {
|
|
174
|
+
readonly ok: false;
|
|
175
|
+
readonly reason: "error";
|
|
176
|
+
readonly error: unknown;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* @internal Runs a server function or query on behalf of a non-browser caller, such as an MCP
|
|
180
|
+
* tool call. Runs the same pipeline as a browser action (input schema, middleware, handler,
|
|
181
|
+
* output schema, invalidations) with `request` as the action request, so middleware reads the
|
|
182
|
+
* caller's headers. A query resolves to its data rather than the client cache envelope.
|
|
183
|
+
*/
|
|
184
|
+
declare function _invokeServerFunction(value: unknown, input: unknown, request: Request): Promise<ServerFunctionInvocation>;
|
|
114
185
|
declare function createServerMiddleware<const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly [], TProvidedContext extends object = {}>(options: ServerFnMiddlewareOptions<TMiddlewares, TProvidedContext>): ServerFnMiddleware<AssignContext<ServerFnMiddlewareContext<TMiddlewares>, TProvidedContext>>;
|
|
115
186
|
declare function createServerFn<TInputSchema extends ServerFnSchema, TOutputSchema extends ServerFnSchema, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly [], const TErrors extends ServerFnErrorDefinitions = {}>(options: ServerFnOutputOptions<TInputSchema, TOutputSchema, TMiddlewares, TErrors>): ServerFn<InferServerFnSchemaInput<TInputSchema>, Awaited<InferServerFnSchemaOutput<TOutputSchema>>, ServerFnError<TErrors>>;
|
|
116
187
|
declare function createServerFn<TOutputSchema extends ServerFnSchema, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly [], const TErrors extends ServerFnErrorDefinitions = {}>(options: ServerFnOutputOptions<undefined, TOutputSchema, TMiddlewares, TErrors>): ServerFn<unknown, Awaited<InferServerFnSchemaOutput<TOutputSchema>>, ServerFnError<TErrors>>;
|
|
@@ -118,4 +189,4 @@ declare function createServerFn<TSchema extends ServerFnSchema, TResult, const T
|
|
|
118
189
|
declare function createServerFn<TResult, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly [], const TErrors extends ServerFnErrorDefinitions = {}>(options: ServerFnOptions<undefined, TResult, TMiddlewares, TErrors>): ServerFn<unknown, Awaited<TResult>, ServerFnError<TErrors>>;
|
|
119
190
|
declare function _parseServerFnSchema(schema: ServerFnSchema | undefined, value: unknown, contract: "input" | "output", owner?: string): Promise<any>;
|
|
120
191
|
|
|
121
|
-
export { type AnyServerFnMiddleware, FARM_SERVER_FN_SYMBOL, type InferServerFnError, type InferServerFnSchemaInput, type InferServerFnSchemaOutput, ServerActionError, type ServerFn, type ServerFnContext, type ServerFnDeclaredError, type ServerFnError, type ServerFnErrorDefinition, type ServerFnErrorDefinitions, type ServerFnErrorHandler, type ServerFnErrorSchema, ServerFnFailure, type ServerFnFormInput, type ServerFnHandler, type ServerFnHandlerContext, type ServerFnInvalidationContext, type ServerFnInvalidations, type ServerFnMiddleware, type ServerFnMiddlewareContext, type ServerFnMiddlewareContinuation, type ServerFnMiddlewareHandler, type ServerFnMiddlewareHandlerContext, type ServerFnMiddlewareNext, type ServerFnMiddlewareOptions, type ServerFnOptions, type ServerFnOutputOptions, type ServerFnSchema, _parseServerFnSchema, createServerFn, createServerMiddleware };
|
|
192
|
+
export { type AnyServerFnMiddleware, FARM_SERVER_FN_SYMBOL, type InferServerFnError, type InferServerFnSchemaInput, type InferServerFnSchemaOutput, ServerActionError, type ServerFn, type ServerFnContext, type ServerFnDeclaredError, type ServerFnError, type ServerFnErrorDefinition, type ServerFnErrorDefinitions, type ServerFnErrorHandler, type ServerFnErrorSchema, ServerFnFailure, type ServerFnFormInput, type ServerFnHandler, type ServerFnHandlerContext, type ServerFnInvalidationContext, type ServerFnInvalidations, type ServerFnMCPMetadata, type ServerFnMiddleware, type ServerFnMiddlewareContext, type ServerFnMiddlewareContinuation, type ServerFnMiddlewareHandler, type ServerFnMiddlewareHandlerContext, type ServerFnMiddlewareNext, type ServerFnMiddlewareOptions, type ServerFnOptions, type ServerFnOutputOptions, type ServerFnSchema, type ServerFunctionDescriptor, type ServerFunctionInvocation, _attachServerFunctionDescriptor, _describeServerFunction, _invokeServerFunction, _parseServerFnSchema, _runServerFunctionForCaller, createServerFn, createServerFunctionDescriptor, createServerMiddleware };
|
package/dist/server-fn.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FarmCacheInvalidationTarget } from './cache.js';
|
|
2
2
|
import { S as ServerFnFailure, a as ServerActionError } from './server-fn-error-DDh14a0V.js';
|
|
3
3
|
export { F as FARM_SERVER_FN_FAILURE_SYMBOL, b as SerializedServerFnFailure, c as createServerFnTransportError, i as isServerFnFailure } from './server-fn-error-DDh14a0V.js';
|
|
4
|
+
import { d as EndpointMCPMetadata } from './endpoint-kSAxE52R.js';
|
|
4
5
|
|
|
5
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
7
|
type ServerFnSchema = {
|
|
@@ -38,6 +39,10 @@ type ServerFnDeclaredError<TErrors extends ServerFnErrorDefinitions> = {
|
|
|
38
39
|
type ServerFnError<TErrors extends ServerFnErrorDefinitions> = keyof TErrors extends never ? Error : ServerActionError | ServerFnDeclaredError<TErrors>;
|
|
39
40
|
type ServerFnErrorHandler<TErrors extends ServerFnErrorDefinitions> = <TCode extends keyof TErrors & string>(code: TCode, data: InferServerFnSchemaInput<TErrors[TCode]["data"]>) => never;
|
|
40
41
|
type ServerFnFormInput = FormData;
|
|
42
|
+
/** MCP tool metadata for a server function or query. Server functions have no path to derive a name from. */
|
|
43
|
+
type ServerFnMCPMetadata = EndpointMCPMetadata & {
|
|
44
|
+
name: string;
|
|
45
|
+
};
|
|
41
46
|
type Simplify<T> = {
|
|
42
47
|
[TKey in keyof T]: T[TKey];
|
|
43
48
|
} & {};
|
|
@@ -92,6 +97,8 @@ type ServerFnOptions<TSchema extends ServerFnSchema | undefined, TResult, TMiddl
|
|
|
92
97
|
output?: undefined;
|
|
93
98
|
middleware?: TMiddlewares;
|
|
94
99
|
errors?: TErrors;
|
|
100
|
+
/** Expose this function as an MCP tool when it is listed in `mcp.tools`. `name` is required. */
|
|
101
|
+
mcp?: ServerFnMCPMetadata;
|
|
95
102
|
invalidates?: ServerFnInvalidations<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, Awaited<TResult>, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
96
103
|
handler: ServerFnHandler<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, TResult, ServerFnMiddlewareContext<TMiddlewares>, TErrors>;
|
|
97
104
|
};
|
|
@@ -100,6 +107,8 @@ type ServerFnOutputOptions<TInputSchema extends ServerFnSchema | undefined, TOut
|
|
|
100
107
|
output: TOutputSchema;
|
|
101
108
|
middleware?: TMiddlewares;
|
|
102
109
|
errors?: TErrors;
|
|
110
|
+
/** Expose this function as an MCP tool when it is listed in `mcp.tools`. `name` is required. */
|
|
111
|
+
mcp?: ServerFnMCPMetadata;
|
|
103
112
|
invalidates?: ServerFnInvalidations<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, Awaited<InferServerFnSchemaOutput<TOutputSchema>>, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
104
113
|
handler: ServerFnHandler<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, unknown, ServerFnMiddlewareContext<TMiddlewares>, TErrors>;
|
|
105
114
|
};
|
|
@@ -111,6 +120,68 @@ type ServerFn<TInput, TResult, TError extends Error = Error> = ([unknown] extend
|
|
|
111
120
|
};
|
|
112
121
|
type InferServerFnError<TServerFn> = TServerFn extends ServerFn<any, any, infer TError> ? TError : Error;
|
|
113
122
|
declare const FARM_SERVER_FN_SYMBOL: unique symbol;
|
|
123
|
+
/** @internal What a non-browser caller, such as an MCP tool, needs to know about a server function. */
|
|
124
|
+
interface ServerFunctionDescriptor {
|
|
125
|
+
/** Queries only read data; actions may change it. */
|
|
126
|
+
readonly kind: "action" | "query";
|
|
127
|
+
readonly input: ServerFnSchema | undefined;
|
|
128
|
+
readonly output: ServerFnSchema | undefined;
|
|
129
|
+
readonly mcp: Readonly<ServerFnMCPMetadata> | undefined;
|
|
130
|
+
}
|
|
131
|
+
interface ServerFunctionRunner extends ServerFunctionDescriptor {
|
|
132
|
+
/** Runs the full pipeline and labels input validation failures with ServerFnInputError. */
|
|
133
|
+
readonly run: (input: unknown) => Promise<unknown>;
|
|
134
|
+
}
|
|
135
|
+
/** @internal Shared by createServerFn and createServerQuery. */
|
|
136
|
+
declare function createServerFunctionDescriptor(kind: ServerFunctionDescriptor["kind"], options: {
|
|
137
|
+
input?: ServerFnSchema;
|
|
138
|
+
output?: ServerFnSchema;
|
|
139
|
+
mcp?: ServerFnMCPMetadata;
|
|
140
|
+
}, run: ServerFunctionRunner["run"]): ServerFunctionRunner;
|
|
141
|
+
/** @internal Attaches the descriptor that `_describeServerFunction` reads. */
|
|
142
|
+
declare function _attachServerFunctionDescriptor(target: object, descriptor: ServerFunctionRunner): void;
|
|
143
|
+
/** @internal Runs a server function's pipeline with input failures labelled, for createServerQuery. */
|
|
144
|
+
declare function _runServerFunctionForCaller(value: unknown, input: unknown): Promise<unknown>;
|
|
145
|
+
/**
|
|
146
|
+
* @internal Describes a createServerFn or createServerQuery function, or returns undefined for
|
|
147
|
+
* anything else. Exposes schemas and metadata, never the handler.
|
|
148
|
+
*/
|
|
149
|
+
declare function _describeServerFunction(value: unknown): ServerFunctionDescriptor | undefined;
|
|
150
|
+
/** @internal How a server function call ended, for callers that are not the browser action transport. */
|
|
151
|
+
type ServerFunctionInvocation = {
|
|
152
|
+
readonly ok: true;
|
|
153
|
+
readonly data: unknown;
|
|
154
|
+
}
|
|
155
|
+
/** The caller's input failed the input schema. The validator's error describes the caller's own data. */
|
|
156
|
+
| {
|
|
157
|
+
readonly ok: false;
|
|
158
|
+
readonly reason: "input";
|
|
159
|
+
readonly error: unknown;
|
|
160
|
+
}
|
|
161
|
+
/** A failure declared in `errors`, public by design. */
|
|
162
|
+
| {
|
|
163
|
+
readonly ok: false;
|
|
164
|
+
readonly reason: "failure";
|
|
165
|
+
readonly failure: ServerFnFailure;
|
|
166
|
+
} | {
|
|
167
|
+
readonly ok: false;
|
|
168
|
+
readonly reason: "redirect";
|
|
169
|
+
readonly url: string;
|
|
170
|
+
readonly status: number;
|
|
171
|
+
}
|
|
172
|
+
/** Anything else. Can contain private data, so callers must not expose it. */
|
|
173
|
+
| {
|
|
174
|
+
readonly ok: false;
|
|
175
|
+
readonly reason: "error";
|
|
176
|
+
readonly error: unknown;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* @internal Runs a server function or query on behalf of a non-browser caller, such as an MCP
|
|
180
|
+
* tool call. Runs the same pipeline as a browser action (input schema, middleware, handler,
|
|
181
|
+
* output schema, invalidations) with `request` as the action request, so middleware reads the
|
|
182
|
+
* caller's headers. A query resolves to its data rather than the client cache envelope.
|
|
183
|
+
*/
|
|
184
|
+
declare function _invokeServerFunction(value: unknown, input: unknown, request: Request): Promise<ServerFunctionInvocation>;
|
|
114
185
|
declare function createServerMiddleware<const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly [], TProvidedContext extends object = {}>(options: ServerFnMiddlewareOptions<TMiddlewares, TProvidedContext>): ServerFnMiddleware<AssignContext<ServerFnMiddlewareContext<TMiddlewares>, TProvidedContext>>;
|
|
115
186
|
declare function createServerFn<TInputSchema extends ServerFnSchema, TOutputSchema extends ServerFnSchema, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly [], const TErrors extends ServerFnErrorDefinitions = {}>(options: ServerFnOutputOptions<TInputSchema, TOutputSchema, TMiddlewares, TErrors>): ServerFn<InferServerFnSchemaInput<TInputSchema>, Awaited<InferServerFnSchemaOutput<TOutputSchema>>, ServerFnError<TErrors>>;
|
|
116
187
|
declare function createServerFn<TOutputSchema extends ServerFnSchema, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly [], const TErrors extends ServerFnErrorDefinitions = {}>(options: ServerFnOutputOptions<undefined, TOutputSchema, TMiddlewares, TErrors>): ServerFn<unknown, Awaited<InferServerFnSchemaOutput<TOutputSchema>>, ServerFnError<TErrors>>;
|
|
@@ -118,4 +189,4 @@ declare function createServerFn<TSchema extends ServerFnSchema, TResult, const T
|
|
|
118
189
|
declare function createServerFn<TResult, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly [], const TErrors extends ServerFnErrorDefinitions = {}>(options: ServerFnOptions<undefined, TResult, TMiddlewares, TErrors>): ServerFn<unknown, Awaited<TResult>, ServerFnError<TErrors>>;
|
|
119
190
|
declare function _parseServerFnSchema(schema: ServerFnSchema | undefined, value: unknown, contract: "input" | "output", owner?: string): Promise<any>;
|
|
120
191
|
|
|
121
|
-
export { type AnyServerFnMiddleware, FARM_SERVER_FN_SYMBOL, type InferServerFnError, type InferServerFnSchemaInput, type InferServerFnSchemaOutput, ServerActionError, type ServerFn, type ServerFnContext, type ServerFnDeclaredError, type ServerFnError, type ServerFnErrorDefinition, type ServerFnErrorDefinitions, type ServerFnErrorHandler, type ServerFnErrorSchema, ServerFnFailure, type ServerFnFormInput, type ServerFnHandler, type ServerFnHandlerContext, type ServerFnInvalidationContext, type ServerFnInvalidations, type ServerFnMiddleware, type ServerFnMiddlewareContext, type ServerFnMiddlewareContinuation, type ServerFnMiddlewareHandler, type ServerFnMiddlewareHandlerContext, type ServerFnMiddlewareNext, type ServerFnMiddlewareOptions, type ServerFnOptions, type ServerFnOutputOptions, type ServerFnSchema, _parseServerFnSchema, createServerFn, createServerMiddleware };
|
|
192
|
+
export { type AnyServerFnMiddleware, FARM_SERVER_FN_SYMBOL, type InferServerFnError, type InferServerFnSchemaInput, type InferServerFnSchemaOutput, ServerActionError, type ServerFn, type ServerFnContext, type ServerFnDeclaredError, type ServerFnError, type ServerFnErrorDefinition, type ServerFnErrorDefinitions, type ServerFnErrorHandler, type ServerFnErrorSchema, ServerFnFailure, type ServerFnFormInput, type ServerFnHandler, type ServerFnHandlerContext, type ServerFnInvalidationContext, type ServerFnInvalidations, type ServerFnMCPMetadata, type ServerFnMiddleware, type ServerFnMiddlewareContext, type ServerFnMiddlewareContinuation, type ServerFnMiddlewareHandler, type ServerFnMiddlewareHandlerContext, type ServerFnMiddlewareNext, type ServerFnMiddlewareOptions, type ServerFnOptions, type ServerFnOutputOptions, type ServerFnSchema, type ServerFunctionDescriptor, type ServerFunctionInvocation, _attachServerFunctionDescriptor, _describeServerFunction, _invokeServerFunction, _parseServerFnSchema, _runServerFunctionForCaller, createServerFn, createServerFunctionDescriptor, createServerMiddleware };
|
package/dist/server-fn.mjs
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FARM_SERVER_FN_SYMBOL,
|
|
3
|
+
_attachServerFunctionDescriptor,
|
|
4
|
+
_describeServerFunction,
|
|
5
|
+
_invokeServerFunction,
|
|
3
6
|
_parseServerFnSchema,
|
|
7
|
+
_runServerFunctionForCaller,
|
|
4
8
|
createServerFn,
|
|
9
|
+
createServerFunctionDescriptor,
|
|
5
10
|
createServerMiddleware
|
|
6
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-VVTREAG5.mjs";
|
|
7
12
|
import {
|
|
8
13
|
FARM_SERVER_FN_FAILURE_SYMBOL,
|
|
9
14
|
ServerActionError,
|
|
@@ -17,6 +22,7 @@ import "./chunk-IGO2HEV7.mjs";
|
|
|
17
22
|
import "./chunk-4SIYUGRY.mjs";
|
|
18
23
|
import "./chunk-C4NCTZLM.mjs";
|
|
19
24
|
import "./chunk-FUZEBRP3.mjs";
|
|
25
|
+
import "./chunk-CBBLJMR5.mjs";
|
|
20
26
|
import "./chunk-IZY3V5XW.mjs";
|
|
21
27
|
import "./chunk-55YI3RRB.mjs";
|
|
22
28
|
import "./chunk-LPEX4YW6.mjs";
|
|
@@ -25,9 +31,14 @@ export {
|
|
|
25
31
|
FARM_SERVER_FN_SYMBOL,
|
|
26
32
|
ServerActionError,
|
|
27
33
|
ServerFnFailure,
|
|
34
|
+
_attachServerFunctionDescriptor,
|
|
35
|
+
_describeServerFunction,
|
|
36
|
+
_invokeServerFunction,
|
|
28
37
|
_parseServerFnSchema,
|
|
38
|
+
_runServerFunctionForCaller,
|
|
29
39
|
createServerFn,
|
|
30
40
|
createServerFnTransportError,
|
|
41
|
+
createServerFunctionDescriptor,
|
|
31
42
|
createServerMiddleware,
|
|
32
43
|
isServerFnFailure
|
|
33
44
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { ch as RedirectConfig, b as FarmRequest, c as FarmResponse, d as FarmPluginContext, a as FarmPlugin, ci as HeaderConfig, cj as RewriteConfig } from './client-plugins-CIPRtSsW.mjs';
|
|
2
|
+
export { bF as FarmPluginLifecycle, bO as FarmPluginRuntimeEndpoint, bP as FarmPluginRuntimeEndpointEvent, bG as FarmRequestPluginContext, bH as FarmRequestStore } from './client-plugins-CIPRtSsW.mjs';
|
|
3
3
|
import { R as ResolvedFarmI18nConfig } from './types-Z0aotQ8w.mjs';
|
|
4
4
|
export { createCompressionPlugin } from './internal/compression-runtime.mjs';
|
|
5
5
|
import './lifecycle-DK06VuKP.mjs';
|
|
6
|
-
import './route-
|
|
6
|
+
import './route-C_eLaFTZ.mjs';
|
|
7
|
+
import './endpoint-Bu3XgeMK.mjs';
|
|
7
8
|
import './cache.mjs';
|
|
8
9
|
import './renderer.mjs';
|
|
9
10
|
import './deployment.mjs';
|
|
@@ -29,6 +30,8 @@ import './server-action-security.mjs';
|
|
|
29
30
|
import './server-fn-error-DDh14a0V.mjs';
|
|
30
31
|
import 'esbuild';
|
|
31
32
|
import './image-config-Duob7wER.mjs';
|
|
33
|
+
import './server-fn.mjs';
|
|
34
|
+
import './server-query.mjs';
|
|
32
35
|
import './types-DQnyD3VD.mjs';
|
|
33
36
|
import './font.mjs';
|
|
34
37
|
import './after.mjs';
|
package/dist/server-plugins.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { ch as RedirectConfig, b as FarmRequest, c as FarmResponse, d as FarmPluginContext, a as FarmPlugin, ci as HeaderConfig, cj as RewriteConfig } from './client-plugins-CqVtZi5X.js';
|
|
2
|
+
export { bF as FarmPluginLifecycle, bO as FarmPluginRuntimeEndpoint, bP as FarmPluginRuntimeEndpointEvent, bG as FarmRequestPluginContext, bH as FarmRequestStore } from './client-plugins-CqVtZi5X.js';
|
|
3
3
|
import { R as ResolvedFarmI18nConfig } from './types-Z0aotQ8w.js';
|
|
4
4
|
export { createCompressionPlugin } from './internal/compression-runtime.js';
|
|
5
5
|
import './lifecycle-DK06VuKP.js';
|
|
6
|
-
import './route-
|
|
6
|
+
import './route-BxNJT447.js';
|
|
7
|
+
import './endpoint-kSAxE52R.js';
|
|
7
8
|
import './cache.js';
|
|
8
9
|
import './renderer.js';
|
|
9
10
|
import './deployment.js';
|
|
@@ -29,6 +30,8 @@ import './server-action-security.js';
|
|
|
29
30
|
import './server-fn-error-DDh14a0V.js';
|
|
30
31
|
import 'esbuild';
|
|
31
32
|
import './image-config-Duob7wER.js';
|
|
33
|
+
import './server-fn.js';
|
|
34
|
+
import './server-query.js';
|
|
32
35
|
import './types-DQnyD3VD.js';
|
|
33
36
|
import './font.js';
|
|
34
37
|
import './after.js';
|
|
@@ -5,6 +5,7 @@ export { F as FarmServerQueryActionInvocation, b as beginFarmServerQueryAction,
|
|
|
5
5
|
import './cache.mjs';
|
|
6
6
|
import './server-fn.mjs';
|
|
7
7
|
import './server-fn-error-DDh14a0V.mjs';
|
|
8
|
+
import './endpoint-Bu3XgeMK.mjs';
|
|
8
9
|
|
|
9
10
|
type UseServerQueryOptions = ServerQueryFetchOptions & {
|
|
10
11
|
enabled?: boolean;
|
|
@@ -5,6 +5,7 @@ export { F as FarmServerQueryActionInvocation, b as beginFarmServerQueryAction,
|
|
|
5
5
|
import './cache.js';
|
|
6
6
|
import './server-fn.js';
|
|
7
7
|
import './server-fn-error-DDh14a0V.js';
|
|
8
|
+
import './endpoint-kSAxE52R.js';
|
|
8
9
|
|
|
9
10
|
type UseServerQueryOptions = ServerQueryFetchOptions & {
|
|
10
11
|
enabled?: boolean;
|
package/dist/server-query.cjs
CHANGED
|
@@ -1343,6 +1343,43 @@ __name(_resolveCurrentRequest, "_resolveCurrentRequest");
|
|
|
1343
1343
|
|
|
1344
1344
|
// src/server-fn.ts
|
|
1345
1345
|
var FARM_SERVER_FN_SYMBOL = /* @__PURE__ */ Symbol.for("farm.server-fn");
|
|
1346
|
+
var FARM_SERVER_FUNCTION_DESCRIPTOR = /* @__PURE__ */ Symbol.for("farm.server-function.descriptor");
|
|
1347
|
+
var _ServerFnInputError = class _ServerFnInputError extends Error {
|
|
1348
|
+
constructor(cause) {
|
|
1349
|
+
super("Server function input is invalid");
|
|
1350
|
+
this.cause = cause;
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
__name(_ServerFnInputError, "ServerFnInputError");
|
|
1354
|
+
var ServerFnInputError = _ServerFnInputError;
|
|
1355
|
+
function createServerFunctionDescriptor(kind, options, run) {
|
|
1356
|
+
return Object.freeze({
|
|
1357
|
+
kind,
|
|
1358
|
+
input: options.input,
|
|
1359
|
+
output: options.output,
|
|
1360
|
+
mcp: options.mcp === void 0 ? void 0 : Object.freeze({ ...options.mcp }),
|
|
1361
|
+
run
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
__name(createServerFunctionDescriptor, "createServerFunctionDescriptor");
|
|
1365
|
+
function _attachServerFunctionDescriptor(target, descriptor) {
|
|
1366
|
+
Object.defineProperty(target, FARM_SERVER_FUNCTION_DESCRIPTOR, {
|
|
1367
|
+
value: descriptor,
|
|
1368
|
+
enumerable: false
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
__name(_attachServerFunctionDescriptor, "_attachServerFunctionDescriptor");
|
|
1372
|
+
function getServerFunctionRunner(value) {
|
|
1373
|
+
if (typeof value !== "function") return void 0;
|
|
1374
|
+
return value[FARM_SERVER_FUNCTION_DESCRIPTOR];
|
|
1375
|
+
}
|
|
1376
|
+
__name(getServerFunctionRunner, "getServerFunctionRunner");
|
|
1377
|
+
function _runServerFunctionForCaller(value, input) {
|
|
1378
|
+
const runner = getServerFunctionRunner(value);
|
|
1379
|
+
if (!runner) throw new TypeError("Expected a function created with createServerFn");
|
|
1380
|
+
return runner.run(input);
|
|
1381
|
+
}
|
|
1382
|
+
__name(_runServerFunctionForCaller, "_runServerFunctionForCaller");
|
|
1346
1383
|
var UNSAFE_FORM_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
1347
1384
|
function createServerFn(options) {
|
|
1348
1385
|
if (!options || typeof options.handler !== "function") {
|
|
@@ -1351,10 +1388,15 @@ function createServerFn(options) {
|
|
|
1351
1388
|
const middleware = resolveServerFnMiddleware(options.middleware);
|
|
1352
1389
|
const errors = normalizeServerFnErrors(options.errors);
|
|
1353
1390
|
const error = createServerFnErrorHandler(errors);
|
|
1354
|
-
const
|
|
1391
|
+
const run = /* @__PURE__ */ __name(async (value, labelInputErrors) => {
|
|
1355
1392
|
const formData = isFormData(value) ? value : void 0;
|
|
1356
1393
|
const rawInput = formData ? formDataToObject(formData) : value;
|
|
1357
|
-
|
|
1394
|
+
let input;
|
|
1395
|
+
try {
|
|
1396
|
+
input = await _parseServerFnSchema(options.input, rawInput, "input");
|
|
1397
|
+
} catch (cause) {
|
|
1398
|
+
throw labelInputErrors ? new ServerFnInputError(cause) : cause;
|
|
1399
|
+
}
|
|
1358
1400
|
const executionContext = getServerActionExecutionContext();
|
|
1359
1401
|
const request = executionContext?.request ?? _resolveCurrentRequest();
|
|
1360
1402
|
const signal = executionContext?.signal ?? request?.signal ?? getServerActionSignal();
|
|
@@ -1380,7 +1422,8 @@ function createServerFn(options) {
|
|
|
1380
1422
|
await applyFarmCacheInvalidationTargets(declaration);
|
|
1381
1423
|
}
|
|
1382
1424
|
return parsedResult;
|
|
1383
|
-
}, "
|
|
1425
|
+
}, "run");
|
|
1426
|
+
const serverFn = /* @__PURE__ */ __name((value) => run(value, false), "serverFn");
|
|
1384
1427
|
Object.defineProperties(serverFn, {
|
|
1385
1428
|
[FARM_SERVER_FN_SYMBOL]: {
|
|
1386
1429
|
value: true,
|
|
@@ -1411,6 +1454,10 @@ function createServerFn(options) {
|
|
|
1411
1454
|
enumerable: false
|
|
1412
1455
|
}
|
|
1413
1456
|
});
|
|
1457
|
+
_attachServerFunctionDescriptor(
|
|
1458
|
+
serverFn,
|
|
1459
|
+
createServerFunctionDescriptor("action", options, (value) => run(value, true))
|
|
1460
|
+
);
|
|
1414
1461
|
return serverFn;
|
|
1415
1462
|
}
|
|
1416
1463
|
__name(createServerFn, "createServerFn");
|
|
@@ -1687,6 +1734,16 @@ function createServerQuery(options) {
|
|
|
1687
1734
|
enumerable: false
|
|
1688
1735
|
}
|
|
1689
1736
|
});
|
|
1737
|
+
_attachServerFunctionDescriptor(
|
|
1738
|
+
query,
|
|
1739
|
+
createServerFunctionDescriptor("query", options, async (value) => {
|
|
1740
|
+
const result = await _runServerFunctionForCaller(
|
|
1741
|
+
execute,
|
|
1742
|
+
value
|
|
1743
|
+
);
|
|
1744
|
+
return result.data;
|
|
1745
|
+
})
|
|
1746
|
+
);
|
|
1690
1747
|
return query;
|
|
1691
1748
|
}
|
|
1692
1749
|
__name(createServerQuery, "createServerQuery");
|
package/dist/server-query.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RouteDataCacheKey } from './cache.mjs';
|
|
2
|
-
import { ServerFnContext, ServerFnSchema, AnyServerFnMiddleware, InferServerFnSchemaOutput, ServerFnMiddlewareContext, ServerFnHandler, InferServerFnSchemaInput } from './server-fn.mjs';
|
|
2
|
+
import { ServerFnContext, ServerFnSchema, AnyServerFnMiddleware, InferServerFnSchemaOutput, ServerFnMiddlewareContext, ServerFnMCPMetadata, ServerFnHandler, InferServerFnSchemaInput } from './server-fn.mjs';
|
|
3
3
|
import './server-fn-error-DDh14a0V.mjs';
|
|
4
|
+
import './endpoint-Bu3XgeMK.mjs';
|
|
4
5
|
|
|
5
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
7
|
type ServerQueryStaleTime = number | false | `${number}${"ms" | "s" | "m" | "h"}`;
|
|
@@ -14,6 +15,8 @@ type ServerQueryOptions<TSchema extends ServerFnSchema | undefined, TResult, TMi
|
|
|
14
15
|
staleTime?: ServerQueryStaleTime;
|
|
15
16
|
/** Allow the configured client cache persistence adapter to store results on the device. */
|
|
16
17
|
persist?: boolean;
|
|
18
|
+
/** Expose this query as a read-only MCP tool when it is listed in `mcp.tools`. `name` is required. */
|
|
19
|
+
mcp?: ServerFnMCPMetadata;
|
|
17
20
|
handler: ServerFnHandler<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, TResult, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
18
21
|
};
|
|
19
22
|
type ServerQueryOutputOptions<TInputSchema extends ServerFnSchema | undefined, TOutputSchema extends ServerFnSchema, TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []> = {
|
|
@@ -25,6 +28,8 @@ type ServerQueryOutputOptions<TInputSchema extends ServerFnSchema | undefined, T
|
|
|
25
28
|
staleTime?: ServerQueryStaleTime;
|
|
26
29
|
/** Allow the configured client cache persistence adapter to store results on the device. */
|
|
27
30
|
persist?: boolean;
|
|
31
|
+
/** Expose this query as a read-only MCP tool when it is listed in `mcp.tools`. `name` is required. */
|
|
32
|
+
mcp?: ServerFnMCPMetadata;
|
|
28
33
|
handler: ServerFnHandler<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, unknown, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
29
34
|
};
|
|
30
35
|
type ServerQuery<TInput, TResult> = ([unknown] extends [TInput] ? (input?: TInput) => Promise<TResult> : (input: TInput) => Promise<TResult>) & {
|
package/dist/server-query.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RouteDataCacheKey } from './cache.js';
|
|
2
|
-
import { ServerFnContext, ServerFnSchema, AnyServerFnMiddleware, InferServerFnSchemaOutput, ServerFnMiddlewareContext, ServerFnHandler, InferServerFnSchemaInput } from './server-fn.js';
|
|
2
|
+
import { ServerFnContext, ServerFnSchema, AnyServerFnMiddleware, InferServerFnSchemaOutput, ServerFnMiddlewareContext, ServerFnMCPMetadata, ServerFnHandler, InferServerFnSchemaInput } from './server-fn.js';
|
|
3
3
|
import './server-fn-error-DDh14a0V.js';
|
|
4
|
+
import './endpoint-kSAxE52R.js';
|
|
4
5
|
|
|
5
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
7
|
type ServerQueryStaleTime = number | false | `${number}${"ms" | "s" | "m" | "h"}`;
|
|
@@ -14,6 +15,8 @@ type ServerQueryOptions<TSchema extends ServerFnSchema | undefined, TResult, TMi
|
|
|
14
15
|
staleTime?: ServerQueryStaleTime;
|
|
15
16
|
/** Allow the configured client cache persistence adapter to store results on the device. */
|
|
16
17
|
persist?: boolean;
|
|
18
|
+
/** Expose this query as a read-only MCP tool when it is listed in `mcp.tools`. `name` is required. */
|
|
19
|
+
mcp?: ServerFnMCPMetadata;
|
|
17
20
|
handler: ServerFnHandler<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, TResult, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
18
21
|
};
|
|
19
22
|
type ServerQueryOutputOptions<TInputSchema extends ServerFnSchema | undefined, TOutputSchema extends ServerFnSchema, TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []> = {
|
|
@@ -25,6 +28,8 @@ type ServerQueryOutputOptions<TInputSchema extends ServerFnSchema | undefined, T
|
|
|
25
28
|
staleTime?: ServerQueryStaleTime;
|
|
26
29
|
/** Allow the configured client cache persistence adapter to store results on the device. */
|
|
27
30
|
persist?: boolean;
|
|
31
|
+
/** Expose this query as a read-only MCP tool when it is listed in `mcp.tools`. `name` is required. */
|
|
32
|
+
mcp?: ServerFnMCPMetadata;
|
|
28
33
|
handler: ServerFnHandler<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, unknown, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
29
34
|
};
|
|
30
35
|
type ServerQuery<TInput, TResult> = ([unknown] extends [TInput] ? (input?: TInput) => Promise<TResult> : (input: TInput) => Promise<TResult>) & {
|
package/dist/server-query.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FARM_SERVER_QUERY_SYMBOL,
|
|
3
3
|
createServerQuery
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-UQZPTIML.mjs";
|
|
5
|
+
import "./chunk-VVTREAG5.mjs";
|
|
6
6
|
import "./chunk-KGB5UXJJ.mjs";
|
|
7
7
|
import "./chunk-QCFFHV5H.mjs";
|
|
8
8
|
import "./chunk-FP2INE7H.mjs";
|
|
@@ -11,6 +11,7 @@ import "./chunk-IGO2HEV7.mjs";
|
|
|
11
11
|
import "./chunk-4SIYUGRY.mjs";
|
|
12
12
|
import "./chunk-C4NCTZLM.mjs";
|
|
13
13
|
import "./chunk-FUZEBRP3.mjs";
|
|
14
|
+
import "./chunk-CBBLJMR5.mjs";
|
|
14
15
|
import "./chunk-IZY3V5XW.mjs";
|
|
15
16
|
import "./chunk-55YI3RRB.mjs";
|
|
16
17
|
import "./chunk-LPEX4YW6.mjs";
|