@farm.js/core 0.1.0-beta.21 → 0.1.0-beta.22
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/after.d.mts +25 -0
- package/dist/after.d.ts +25 -0
- package/dist/agent-runtime.d.mts +96 -0
- package/dist/agent-runtime.d.ts +96 -0
- package/dist/api/route-manager.d.mts +68 -0
- package/dist/api/route-manager.d.ts +68 -0
- package/dist/api/runtime.d.mts +3 -0
- package/dist/api/runtime.d.ts +3 -0
- package/dist/api.cjs +22 -19
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.mts +50 -0
- package/dist/api.d.ts +50 -0
- package/dist/api.mjs +2 -1
- package/dist/app-BB8GCH1g.d.ts +306 -0
- package/dist/app-DwsTpyNZ.d.mts +306 -0
- package/dist/app-markdown.d.mts +24 -0
- package/dist/app-markdown.d.ts +24 -0
- package/dist/cache.d.mts +192 -0
- package/dist/cache.d.ts +192 -0
- package/dist/{chunk-MIUW47JX.mjs → chunk-2PEJGY5V.mjs} +15 -20
- package/dist/chunk-2PEJGY5V.mjs.map +1 -0
- package/dist/{chunk-RIXKJPGI.mjs → chunk-42325TLU.mjs} +2 -2
- package/dist/{chunk-I3UWA2P2.mjs → chunk-DAUR3WUZ.mjs} +2 -2
- package/dist/{chunk-I3UWA2P2.mjs.map → chunk-DAUR3WUZ.mjs.map} +1 -1
- package/dist/chunk-GIELMNBG.mjs +15 -0
- package/dist/chunk-GIELMNBG.mjs.map +1 -0
- package/dist/{chunk-4EATUJFO.mjs → chunk-ICTGDDV4.mjs} +20 -22
- package/dist/chunk-ICTGDDV4.mjs.map +1 -0
- package/dist/{chunk-FKKM7HVF.mjs → chunk-XBKXKJX5.mjs} +30 -35
- package/dist/chunk-XBKXKJX5.mjs.map +1 -0
- package/dist/{chunk-VIC7NJ77.mjs → chunk-ZP73P4VR.mjs} +2 -2
- package/dist/chunk-recovery-lnQFzcQP.d.mts +26 -0
- package/dist/chunk-recovery-lnQFzcQP.d.ts +26 -0
- package/dist/client-BT1mFQas.d.mts +447 -0
- package/dist/client-Nn0q4eO4.d.ts +447 -0
- package/dist/client-cache-CIlyBlmx.d.ts +6 -0
- package/dist/client-cache-D-EZ7XVW.d.mts +6 -0
- package/dist/client-plugins-CbRum1fj.d.ts +2088 -0
- package/dist/client-plugins-QQntVkrv.d.mts +2088 -0
- package/dist/client-plugins.d.mts +24 -0
- package/dist/client-plugins.d.ts +24 -0
- package/dist/client.d.mts +452 -0
- package/dist/client.d.ts +452 -0
- package/dist/config.d.mts +31 -0
- package/dist/config.d.ts +31 -0
- package/dist/cron.d.mts +78 -0
- package/dist/cron.d.ts +78 -0
- package/dist/deferred.d.mts +42 -0
- package/dist/deferred.d.ts +42 -0
- package/dist/deployment.d.mts +36 -0
- package/dist/deployment.d.ts +36 -0
- package/dist/docs.d.mts +80 -0
- package/dist/docs.d.ts +80 -0
- package/dist/env-types.d.mts +12 -0
- package/dist/env-types.d.ts +12 -0
- package/dist/env.d.mts +45 -0
- package/dist/env.d.ts +45 -0
- package/dist/environment/vite.d.mts +22 -0
- package/dist/environment/vite.d.ts +22 -0
- package/dist/environment.d.mts +18 -0
- package/dist/environment.d.ts +18 -0
- package/dist/font.d.mts +95 -0
- package/dist/font.d.ts +95 -0
- package/dist/headers.d.mts +22 -0
- package/dist/headers.d.ts +22 -0
- package/dist/i18n/client.d.mts +32 -0
- package/dist/i18n/client.d.ts +32 -0
- package/dist/i18n/index.d.mts +20 -0
- package/dist/i18n/index.d.ts +20 -0
- package/dist/i18n/server.d.mts +30 -0
- package/dist/i18n/server.d.ts +30 -0
- package/dist/image/server.d.mts +37 -0
- package/dist/image/server.d.ts +37 -0
- package/dist/image/sharp.d.mts +7 -0
- package/dist/image/sharp.d.ts +7 -0
- package/dist/image-config-Duob7wER.d.mts +50 -0
- package/dist/image-config-Duob7wER.d.ts +50 -0
- package/dist/image.d.mts +39 -0
- package/dist/image.d.ts +39 -0
- package/dist/index.cjs +66 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +477 -0
- package/dist/index.d.ts +477 -0
- package/dist/index.mjs +7 -6
- package/dist/index.mjs.map +1 -1
- package/dist/integration-api-CHT2OKAf.d.mts +93 -0
- package/dist/integration-api-CHT2OKAf.d.ts +93 -0
- package/dist/integrations.d.mts +24 -0
- package/dist/integrations.d.ts +24 -0
- package/dist/internal/build-runtime.cjs +50 -50
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.d.mts +41 -0
- package/dist/internal/build-runtime.d.ts +41 -0
- package/dist/internal/build-runtime.mjs +5 -4
- package/dist/internal/client-runtime.d.mts +17 -0
- package/dist/internal/client-runtime.d.ts +17 -0
- package/dist/internal/config-runtime.d.mts +41 -0
- package/dist/internal/config-runtime.d.ts +41 -0
- package/dist/internal/metadata-image-runtime.d.mts +25 -0
- package/dist/internal/metadata-image-runtime.d.ts +25 -0
- package/dist/internal/production-node-env.d.mts +12 -0
- package/dist/internal/production-node-env.d.ts +12 -0
- package/dist/internal/production-runtime.d.mts +66 -0
- package/dist/internal/production-runtime.d.ts +66 -0
- package/dist/island-CfGru1MO.d.mts +9 -0
- package/dist/island-CfGru1MO.d.ts +9 -0
- package/dist/markdown.d.mts +60 -0
- package/dist/markdown.d.ts +60 -0
- package/dist/metadata-B5jBJHq1.d.ts +22 -0
- package/dist/metadata-BxOJ4FJl.d.mts +22 -0
- package/dist/middleware.cjs +17 -17
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.mts +171 -0
- package/dist/middleware.d.ts +171 -0
- package/dist/middleware.mjs +3 -2
- package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
- package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
- package/dist/navigation.d.mts +14 -0
- package/dist/navigation.d.ts +14 -0
- package/dist/observability.d.mts +335 -0
- package/dist/observability.d.ts +335 -0
- package/dist/params-BALtrRim.d.ts +15 -0
- package/dist/params-ry-lxqmy.d.mts +15 -0
- package/dist/plugin-BJDf43dc.d.mts +165 -0
- package/dist/plugin-BJDf43dc.d.ts +165 -0
- package/dist/plugin.cjs +42 -48
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +24 -0
- package/dist/plugin.d.ts +24 -0
- package/dist/plugin.mjs +4 -3
- package/dist/production-runtime-Bxua86uR.d.mts +81 -0
- package/dist/production-runtime-CZqXjRVi.d.ts +81 -0
- package/dist/query/client.d.mts +61 -0
- package/dist/query/client.d.ts +61 -0
- package/dist/query/index.d.mts +90 -0
- package/dist/query/index.d.ts +90 -0
- package/dist/query/parsers.d.mts +25 -0
- package/dist/query/parsers.d.ts +25 -0
- package/dist/query/server.d.mts +55 -0
- package/dist/query/server.d.ts +55 -0
- package/dist/request-7V0GaZK_.d.mts +6 -0
- package/dist/request-B5XYBv5a.d.ts +6 -0
- package/dist/request.d.mts +25 -0
- package/dist/request.d.ts +25 -0
- package/dist/resolver-DJqjLMg_.d.mts +14 -0
- package/dist/resolver-IH4RmPEl.d.ts +14 -0
- package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
- package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
- package/dist/router.d.mts +36 -0
- package/dist/router.d.ts +36 -0
- package/dist/routes.d.mts +226 -0
- package/dist/routes.d.ts +226 -0
- package/dist/runtime-Bpp-c28k.d.ts +231 -0
- package/dist/runtime-Cxpq6xZN.d.mts +27 -0
- package/dist/runtime-Q3u74Nbq.d.mts +231 -0
- package/dist/runtime-bv63eUiO.d.ts +27 -0
- package/dist/server-action-security.d.mts +45 -0
- package/dist/server-action-security.d.ts +45 -0
- package/dist/server-fn-client.d.mts +33 -0
- package/dist/server-fn-client.d.ts +33 -0
- package/dist/server-fn-error-DDh14a0V.d.mts +26 -0
- package/dist/server-fn-error-DDh14a0V.d.ts +26 -0
- package/dist/server-fn.d.mts +121 -0
- package/dist/server-fn.d.ts +121 -0
- package/dist/server-plugins.d.mts +57 -0
- package/dist/server-plugins.d.ts +57 -0
- package/dist/server-query-client.d.mts +51 -0
- package/dist/server-query-client.d.ts +51 -0
- package/dist/server-query.d.mts +37 -0
- package/dist/server-query.d.ts +37 -0
- package/dist/server.cjs +45 -67
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +51 -0
- package/dist/server.d.ts +51 -0
- package/dist/server.mjs +8 -22
- package/dist/server.mjs.map +1 -1
- package/dist/storage.d.mts +52 -0
- package/dist/storage.d.ts +52 -0
- package/dist/testing.d.mts +103 -0
- package/dist/testing.d.ts +103 -0
- package/dist/transport-BmbGTXA5.d.mts +49 -0
- package/dist/transport-BmbGTXA5.d.ts +49 -0
- package/dist/types-BMxWr97v.d.mts +81 -0
- package/dist/types-BMxWr97v.d.ts +81 -0
- package/dist/types-D1A6-XvH.d.mts +73 -0
- package/dist/types-D1A6-XvH.d.ts +73 -0
- package/dist/types-DTzm4TCl.d.mts +78 -0
- package/dist/types-DTzm4TCl.d.ts +78 -0
- package/dist/utils-s9pN0Yep.d.mts +23 -0
- package/dist/utils-xTFxzu47.d.ts +23 -0
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.mts +3 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +44 -50
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +24 -0
- package/dist/vite.d.ts +24 -0
- package/dist/vite.mjs +4 -3
- package/dist/workflows-CusFV6mn.d.mts +153 -0
- package/dist/workflows-CusFV6mn.d.ts +153 -0
- package/dist/workflows.d.mts +1 -0
- package/dist/workflows.d.ts +1 -0
- package/package.json +1 -1
- package/dist/chunk-4EATUJFO.mjs.map +0 -1
- package/dist/chunk-FKKM7HVF.mjs.map +0 -1
- package/dist/chunk-MIUW47JX.mjs.map +0 -1
- /package/dist/{chunk-RIXKJPGI.mjs.map → chunk-42325TLU.mjs.map} +0 -0
- /package/dist/{chunk-VIC7NJ77.mjs.map → chunk-ZP73P4VR.mjs.map} +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { FarmCacheInvalidationTarget } from './cache.js';
|
|
2
|
+
import { S as ServerFnFailure, a as ServerActionError } from './server-fn-error-DDh14a0V.js';
|
|
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
|
+
|
|
5
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
6
|
+
type ServerFnSchema = {
|
|
7
|
+
_input?: any;
|
|
8
|
+
_output?: any;
|
|
9
|
+
parse?: (data: unknown) => any;
|
|
10
|
+
parseAsync?: (data: unknown) => Promise<any>;
|
|
11
|
+
safeParse?: (data: unknown) => any;
|
|
12
|
+
safeParseAsync?: (data: unknown) => Promise<any>;
|
|
13
|
+
};
|
|
14
|
+
type InferServerFnSchemaInput<T> = T extends {
|
|
15
|
+
_input: infer I;
|
|
16
|
+
} ? I : unknown;
|
|
17
|
+
type InferServerFnSchemaOutput<T> = T extends {
|
|
18
|
+
_output: infer O;
|
|
19
|
+
} ? O : T extends {
|
|
20
|
+
parse: (data: unknown) => infer R;
|
|
21
|
+
} ? R : unknown;
|
|
22
|
+
type ServerFnErrorSchema = ServerFnSchema & ({
|
|
23
|
+
parse: (data: unknown) => unknown;
|
|
24
|
+
} | {
|
|
25
|
+
safeParse: (data: unknown) => unknown;
|
|
26
|
+
});
|
|
27
|
+
type ServerFnErrorDefinition<TSchema extends ServerFnErrorSchema = ServerFnErrorSchema, TStatus extends number = number> = {
|
|
28
|
+
status: TStatus;
|
|
29
|
+
/** Schema for the public error payload exposed to callers. */
|
|
30
|
+
data: TSchema;
|
|
31
|
+
/** Public message safe to expose to callers. */
|
|
32
|
+
message?: string;
|
|
33
|
+
};
|
|
34
|
+
type ServerFnErrorDefinitions = Record<string, ServerFnErrorDefinition<ServerFnErrorSchema, number>>;
|
|
35
|
+
type ServerFnDeclaredError<TErrors extends ServerFnErrorDefinitions> = {
|
|
36
|
+
[TCode in keyof TErrors]: ServerFnFailure<TCode & string, InferServerFnSchemaOutput<TErrors[TCode]["data"]>, TErrors[TCode]["status"]>;
|
|
37
|
+
}[keyof TErrors];
|
|
38
|
+
type ServerFnError<TErrors extends ServerFnErrorDefinitions> = keyof TErrors extends never ? Error : ServerActionError | ServerFnDeclaredError<TErrors>;
|
|
39
|
+
type ServerFnErrorHandler<TErrors extends ServerFnErrorDefinitions> = <TCode extends keyof TErrors & string>(code: TCode, data: InferServerFnSchemaInput<TErrors[TCode]["data"]>) => never;
|
|
40
|
+
type ServerFnFormInput = FormData;
|
|
41
|
+
type Simplify<T> = {
|
|
42
|
+
[TKey in keyof T]: T[TKey];
|
|
43
|
+
} & {};
|
|
44
|
+
type AssignContext<TCurrent extends object, TNext extends object> = Simplify<Omit<TCurrent, keyof TNext> & TNext>;
|
|
45
|
+
type MiddlewareContext<TMiddleware> = TMiddleware extends ServerFnMiddleware<infer TContext> ? TContext : {};
|
|
46
|
+
type ServerFnMiddlewareContext<TMiddlewares extends readonly AnyServerFnMiddleware[], TContext extends object = {}> = TMiddlewares extends readonly [infer TMiddleware, ...infer TRest] ? TMiddleware extends AnyServerFnMiddleware ? TRest extends readonly AnyServerFnMiddleware[] ? ServerFnMiddlewareContext<TRest, AssignContext<TContext, MiddlewareContext<TMiddleware>>> : TContext : TContext : number extends TMiddlewares["length"] ? Simplify<TContext & MiddlewareContext<TMiddlewares[number]>> : Simplify<TContext>;
|
|
47
|
+
declare const SERVER_FN_MIDDLEWARE_CONTEXT: unique symbol;
|
|
48
|
+
type ServerFnMiddlewareContinuation<TContext extends object = {}> = {
|
|
49
|
+
readonly [SERVER_FN_MIDDLEWARE_CONTEXT]: TContext;
|
|
50
|
+
};
|
|
51
|
+
type ServerFnMiddlewareNext = <TContext extends object = {}>(options?: {
|
|
52
|
+
context?: TContext;
|
|
53
|
+
}) => Promise<ServerFnMiddlewareContinuation<TContext>>;
|
|
54
|
+
type ServerFnContext<TInput, TContext extends object = {}> = {
|
|
55
|
+
input: TInput;
|
|
56
|
+
rawInput: unknown;
|
|
57
|
+
formData?: FormData;
|
|
58
|
+
/** The action request when invoked across the network. Undefined for direct server calls. */
|
|
59
|
+
request?: Request;
|
|
60
|
+
/** Aborts when the underlying action request is cancelled. */
|
|
61
|
+
signal: AbortSignal;
|
|
62
|
+
/** Context produced by this server function's middleware chain. */
|
|
63
|
+
context: Readonly<TContext>;
|
|
64
|
+
};
|
|
65
|
+
type ServerFnHandlerContext<TInput, TContext extends object = {}, TErrors extends ServerFnErrorDefinitions = {}> = ServerFnContext<TInput, TContext> & {
|
|
66
|
+
/** Return a declared, validated error from this server function. */
|
|
67
|
+
error: ServerFnErrorHandler<TErrors>;
|
|
68
|
+
};
|
|
69
|
+
type ServerFnHandler<TInput, TResult, TContext extends object = {}, TErrors extends ServerFnErrorDefinitions = {}> = (ctx: ServerFnHandlerContext<TInput, TContext, TErrors>) => MaybePromise<TResult>;
|
|
70
|
+
type ServerFnInvalidationContext<TInput, TResult, TContext extends object = {}> = ServerFnContext<TInput, TContext> & {
|
|
71
|
+
/** Parsed value returned by the successful server function. */
|
|
72
|
+
result: TResult;
|
|
73
|
+
};
|
|
74
|
+
type ServerFnInvalidations<TInput, TResult, TContext extends object = {}> = readonly FarmCacheInvalidationTarget[] | ((context: ServerFnInvalidationContext<TInput, TResult, TContext>) => readonly FarmCacheInvalidationTarget[] | Promise<readonly FarmCacheInvalidationTarget[]>);
|
|
75
|
+
type ServerFnMiddlewareHandlerContext<TContext extends object = {}> = ServerFnContext<unknown, TContext> & {
|
|
76
|
+
next: ServerFnMiddlewareNext;
|
|
77
|
+
};
|
|
78
|
+
type ServerFnMiddlewareHandler<TContext extends object = {}, TProvidedContext extends object = {}> = (ctx: ServerFnMiddlewareHandlerContext<TContext>) => MaybePromise<ServerFnMiddlewareContinuation<TProvidedContext>>;
|
|
79
|
+
type ServerFnMiddleware<TContext extends object = {}> = {
|
|
80
|
+
readonly __farmServerFnMiddleware: true;
|
|
81
|
+
readonly __farmServerFnMiddlewareContext?: TContext;
|
|
82
|
+
readonly middleware: readonly AnyServerFnMiddleware[];
|
|
83
|
+
readonly handler: ServerFnMiddlewareHandler<any, any>;
|
|
84
|
+
};
|
|
85
|
+
type AnyServerFnMiddleware = ServerFnMiddleware<any>;
|
|
86
|
+
type ServerFnMiddlewareOptions<TMiddlewares extends readonly AnyServerFnMiddleware[], TProvidedContext extends object> = {
|
|
87
|
+
middleware?: TMiddlewares;
|
|
88
|
+
handler: ServerFnMiddlewareHandler<ServerFnMiddlewareContext<TMiddlewares>, TProvidedContext>;
|
|
89
|
+
};
|
|
90
|
+
type ServerFnOptions<TSchema extends ServerFnSchema | undefined, TResult, TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly [], TErrors extends ServerFnErrorDefinitions = {}> = {
|
|
91
|
+
input?: TSchema;
|
|
92
|
+
output?: undefined;
|
|
93
|
+
middleware?: TMiddlewares;
|
|
94
|
+
errors?: TErrors;
|
|
95
|
+
invalidates?: ServerFnInvalidations<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, Awaited<TResult>, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
96
|
+
handler: ServerFnHandler<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, TResult, ServerFnMiddlewareContext<TMiddlewares>, TErrors>;
|
|
97
|
+
};
|
|
98
|
+
type ServerFnOutputOptions<TInputSchema extends ServerFnSchema | undefined, TOutputSchema extends ServerFnSchema, TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly [], TErrors extends ServerFnErrorDefinitions = {}> = {
|
|
99
|
+
input?: TInputSchema;
|
|
100
|
+
output: TOutputSchema;
|
|
101
|
+
middleware?: TMiddlewares;
|
|
102
|
+
errors?: TErrors;
|
|
103
|
+
invalidates?: ServerFnInvalidations<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, Awaited<InferServerFnSchemaOutput<TOutputSchema>>, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
104
|
+
handler: ServerFnHandler<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, unknown, ServerFnMiddlewareContext<TMiddlewares>, TErrors>;
|
|
105
|
+
};
|
|
106
|
+
type ServerFn<TInput, TResult, TError extends Error = Error> = ([unknown] extends [TInput] ? (input?: TInput | FormData) => Promise<TResult> : (input: TInput | FormData) => Promise<TResult>) & {
|
|
107
|
+
readonly __farmServerFn: true;
|
|
108
|
+
readonly __farmServerFnInput?: unknown;
|
|
109
|
+
readonly __farmServerFnOutput?: unknown;
|
|
110
|
+
readonly __farmServerFnError: TError;
|
|
111
|
+
};
|
|
112
|
+
type InferServerFnError<TServerFn> = TServerFn extends ServerFn<any, any, infer TError> ? TError : Error;
|
|
113
|
+
declare const FARM_SERVER_FN_SYMBOL: unique symbol;
|
|
114
|
+
declare function createServerMiddleware<const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly [], TProvidedContext extends object = {}>(options: ServerFnMiddlewareOptions<TMiddlewares, TProvidedContext>): ServerFnMiddleware<AssignContext<ServerFnMiddlewareContext<TMiddlewares>, TProvidedContext>>;
|
|
115
|
+
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
|
+
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>>;
|
|
117
|
+
declare function createServerFn<TSchema extends ServerFnSchema, TResult, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly [], const TErrors extends ServerFnErrorDefinitions = {}>(options: ServerFnOptions<TSchema, TResult, TMiddlewares, TErrors>): ServerFn<InferServerFnSchemaInput<TSchema>, Awaited<TResult>, ServerFnError<TErrors>>;
|
|
118
|
+
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
|
+
declare function _parseServerFnSchema(schema: ServerFnSchema | undefined, value: unknown, contract: "input" | "output", owner?: string): Promise<any>;
|
|
120
|
+
|
|
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 };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { bi as RedirectConfig, x as FarmRequest, y as FarmResponse, aG as FarmPluginContext, $ as FarmPlugin, bj as HeaderConfig, bk as RewriteConfig } from './client-plugins-QQntVkrv.mjs';
|
|
2
|
+
export { aI as FarmPluginLifecycle, aJ as FarmRequestPluginContext, aK as FarmRequestStore } from './client-plugins-QQntVkrv.mjs';
|
|
3
|
+
import './plugin-BJDf43dc.mjs';
|
|
4
|
+
import 'react';
|
|
5
|
+
import 'http';
|
|
6
|
+
import './types-D1A6-XvH.mjs';
|
|
7
|
+
import 'db0';
|
|
8
|
+
import 'unstorage';
|
|
9
|
+
import './integration-api-CHT2OKAf.mjs';
|
|
10
|
+
import '@farming-labs/orm';
|
|
11
|
+
import './types-DTzm4TCl.mjs';
|
|
12
|
+
import '@farming-labs/docs';
|
|
13
|
+
import './markdown.mjs';
|
|
14
|
+
import './observability.mjs';
|
|
15
|
+
import 'vite';
|
|
16
|
+
import './workflows-CusFV6mn.mjs';
|
|
17
|
+
import './cron.mjs';
|
|
18
|
+
import './env.mjs';
|
|
19
|
+
import './server-action-security.mjs';
|
|
20
|
+
import './server-fn-error-DDh14a0V.mjs';
|
|
21
|
+
import './image-config-Duob7wER.mjs';
|
|
22
|
+
import './types-BMxWr97v.mjs';
|
|
23
|
+
import './cache.mjs';
|
|
24
|
+
import './route-runtime-DoOHzCAD.mjs';
|
|
25
|
+
import './font.mjs';
|
|
26
|
+
|
|
27
|
+
declare function createRedirectsPlugin(redirects: RedirectConfig[], { beforeRequest: overrideBeforeRequest, afterResponse: overrideAfterResponse, }?: {
|
|
28
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
29
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
30
|
+
}): FarmPlugin;
|
|
31
|
+
|
|
32
|
+
declare function createHeadersPlugin(headers: HeaderConfig[], { beforeRequest: overrideBeforeRequest, afterResponse: overrideAfterResponse, }?: {
|
|
33
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
34
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
35
|
+
}): FarmPlugin;
|
|
36
|
+
|
|
37
|
+
declare function createRewritesPlugin(rewrites: RewriteConfig[], { beforeRequest: overrideBeforeRequest, afterResponse: overrideAfterResponse, }?: {
|
|
38
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
39
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
40
|
+
}): FarmPlugin;
|
|
41
|
+
|
|
42
|
+
declare function createEnvPlugin(env: Record<string, string>, { beforeRequest: overrideBeforeRequest, afterResponse: overrideAfterResponse, }?: {
|
|
43
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
44
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
45
|
+
}): FarmPlugin;
|
|
46
|
+
|
|
47
|
+
declare function createCompressionPlugin({ beforeRequest: overrideBeforeRequest, afterResponse: overrideAfterResponse, }?: {
|
|
48
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
49
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
50
|
+
}): FarmPlugin;
|
|
51
|
+
|
|
52
|
+
declare function createLoggerPlugin({ beforeRequest, afterResponse, }?: {
|
|
53
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
54
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
55
|
+
}): FarmPlugin;
|
|
56
|
+
|
|
57
|
+
export { FarmPlugin, FarmPluginContext, HeaderConfig, RedirectConfig, RewriteConfig, createCompressionPlugin, createEnvPlugin, createHeadersPlugin, createLoggerPlugin, createRedirectsPlugin, createRewritesPlugin };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { bi as RedirectConfig, x as FarmRequest, y as FarmResponse, aG as FarmPluginContext, $ as FarmPlugin, bj as HeaderConfig, bk as RewriteConfig } from './client-plugins-CbRum1fj.js';
|
|
2
|
+
export { aI as FarmPluginLifecycle, aJ as FarmRequestPluginContext, aK as FarmRequestStore } from './client-plugins-CbRum1fj.js';
|
|
3
|
+
import './plugin-BJDf43dc.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
import 'http';
|
|
6
|
+
import './types-D1A6-XvH.js';
|
|
7
|
+
import 'db0';
|
|
8
|
+
import 'unstorage';
|
|
9
|
+
import './integration-api-CHT2OKAf.js';
|
|
10
|
+
import '@farming-labs/orm';
|
|
11
|
+
import './types-DTzm4TCl.js';
|
|
12
|
+
import '@farming-labs/docs';
|
|
13
|
+
import './markdown.js';
|
|
14
|
+
import './observability.js';
|
|
15
|
+
import 'vite';
|
|
16
|
+
import './workflows-CusFV6mn.js';
|
|
17
|
+
import './cron.js';
|
|
18
|
+
import './env.js';
|
|
19
|
+
import './server-action-security.js';
|
|
20
|
+
import './server-fn-error-DDh14a0V.js';
|
|
21
|
+
import './image-config-Duob7wER.js';
|
|
22
|
+
import './types-BMxWr97v.js';
|
|
23
|
+
import './cache.js';
|
|
24
|
+
import './route-runtime-DoOHzCAD.js';
|
|
25
|
+
import './font.js';
|
|
26
|
+
|
|
27
|
+
declare function createRedirectsPlugin(redirects: RedirectConfig[], { beforeRequest: overrideBeforeRequest, afterResponse: overrideAfterResponse, }?: {
|
|
28
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
29
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
30
|
+
}): FarmPlugin;
|
|
31
|
+
|
|
32
|
+
declare function createHeadersPlugin(headers: HeaderConfig[], { beforeRequest: overrideBeforeRequest, afterResponse: overrideAfterResponse, }?: {
|
|
33
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
34
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
35
|
+
}): FarmPlugin;
|
|
36
|
+
|
|
37
|
+
declare function createRewritesPlugin(rewrites: RewriteConfig[], { beforeRequest: overrideBeforeRequest, afterResponse: overrideAfterResponse, }?: {
|
|
38
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
39
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
40
|
+
}): FarmPlugin;
|
|
41
|
+
|
|
42
|
+
declare function createEnvPlugin(env: Record<string, string>, { beforeRequest: overrideBeforeRequest, afterResponse: overrideAfterResponse, }?: {
|
|
43
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
44
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
45
|
+
}): FarmPlugin;
|
|
46
|
+
|
|
47
|
+
declare function createCompressionPlugin({ beforeRequest: overrideBeforeRequest, afterResponse: overrideAfterResponse, }?: {
|
|
48
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
49
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
50
|
+
}): FarmPlugin;
|
|
51
|
+
|
|
52
|
+
declare function createLoggerPlugin({ beforeRequest, afterResponse, }?: {
|
|
53
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
54
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmPluginContext) => void | Promise<void>;
|
|
55
|
+
}): FarmPlugin;
|
|
56
|
+
|
|
57
|
+
export { FarmPlugin, FarmPluginContext, HeaderConfig, RedirectConfig, RewriteConfig, createCompressionPlugin, createEnvPlugin, createHeadersPlugin, createLoggerPlugin, createRedirectsPlugin, createRewritesPlugin };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { a as FarmClientCacheStatus } from './client-cache-D-EZ7XVW.mjs';
|
|
2
|
+
import { ServerQuery } from './server-query.mjs';
|
|
3
|
+
import './cache.mjs';
|
|
4
|
+
import './server-fn.mjs';
|
|
5
|
+
import './server-fn-error-DDh14a0V.mjs';
|
|
6
|
+
|
|
7
|
+
declare const FARM_SERVER_QUERY_RESULT_VERSION: 1;
|
|
8
|
+
type FarmServerQueryResult<TData> = {
|
|
9
|
+
__farmServerQuery: {
|
|
10
|
+
version: typeof FARM_SERVER_QUERY_RESULT_VERSION;
|
|
11
|
+
key: string;
|
|
12
|
+
staleTime: number | false;
|
|
13
|
+
updatedAt: number;
|
|
14
|
+
};
|
|
15
|
+
data: TData;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type ServerQueryFetchOptions = {
|
|
19
|
+
/** Used only when a non-Farm transport returns plain data. Farm transports use the declaration. */
|
|
20
|
+
staleTime?: number | false;
|
|
21
|
+
/** Return stale data immediately while refreshing it in the background. Default true. */
|
|
22
|
+
swr?: boolean;
|
|
23
|
+
/** Always wait for a new result. */
|
|
24
|
+
force?: boolean;
|
|
25
|
+
};
|
|
26
|
+
type UseServerQueryOptions = ServerQueryFetchOptions & {
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
refetchOnWindowFocus?: boolean;
|
|
29
|
+
refetchOnReconnect?: boolean;
|
|
30
|
+
};
|
|
31
|
+
type UseServerQueryResult<TData> = {
|
|
32
|
+
data: TData | undefined;
|
|
33
|
+
error: Error | null;
|
|
34
|
+
status: FarmClientCacheStatus;
|
|
35
|
+
pending: boolean;
|
|
36
|
+
fetching: boolean;
|
|
37
|
+
stale: boolean;
|
|
38
|
+
refetch: () => Promise<TData>;
|
|
39
|
+
};
|
|
40
|
+
type FarmServerQueryActionInvocation = {
|
|
41
|
+
actionId: string;
|
|
42
|
+
args: readonly unknown[];
|
|
43
|
+
provisionalKey?: string;
|
|
44
|
+
};
|
|
45
|
+
declare function beginFarmServerQueryAction(actionId: string, args: readonly unknown[]): FarmServerQueryActionInvocation;
|
|
46
|
+
declare function completeFarmServerQueryAction<TData>(invocation: FarmServerQueryActionInvocation, value: TData | FarmServerQueryResult<TData>): TData;
|
|
47
|
+
declare function fetchServerQuery<TInput, TData>(query: ServerQuery<TInput, TData>, input: TInput, options?: ServerQueryFetchOptions): Promise<TData>;
|
|
48
|
+
declare function prefetchServerQuery<TInput, TData>(query: ServerQuery<TInput, TData>, input: TInput, options?: Omit<ServerQueryFetchOptions, "force">): Promise<TData>;
|
|
49
|
+
declare function useServerQuery<TInput, TData>(query: ServerQuery<TInput, TData>, input: TInput, options?: UseServerQueryOptions): UseServerQueryResult<TData>;
|
|
50
|
+
|
|
51
|
+
export { type FarmServerQueryActionInvocation, type ServerQueryFetchOptions, type UseServerQueryOptions, type UseServerQueryResult, beginFarmServerQueryAction, completeFarmServerQueryAction, fetchServerQuery, prefetchServerQuery, useServerQuery };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { a as FarmClientCacheStatus } from './client-cache-CIlyBlmx.js';
|
|
2
|
+
import { ServerQuery } from './server-query.js';
|
|
3
|
+
import './cache.js';
|
|
4
|
+
import './server-fn.js';
|
|
5
|
+
import './server-fn-error-DDh14a0V.js';
|
|
6
|
+
|
|
7
|
+
declare const FARM_SERVER_QUERY_RESULT_VERSION: 1;
|
|
8
|
+
type FarmServerQueryResult<TData> = {
|
|
9
|
+
__farmServerQuery: {
|
|
10
|
+
version: typeof FARM_SERVER_QUERY_RESULT_VERSION;
|
|
11
|
+
key: string;
|
|
12
|
+
staleTime: number | false;
|
|
13
|
+
updatedAt: number;
|
|
14
|
+
};
|
|
15
|
+
data: TData;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type ServerQueryFetchOptions = {
|
|
19
|
+
/** Used only when a non-Farm transport returns plain data. Farm transports use the declaration. */
|
|
20
|
+
staleTime?: number | false;
|
|
21
|
+
/** Return stale data immediately while refreshing it in the background. Default true. */
|
|
22
|
+
swr?: boolean;
|
|
23
|
+
/** Always wait for a new result. */
|
|
24
|
+
force?: boolean;
|
|
25
|
+
};
|
|
26
|
+
type UseServerQueryOptions = ServerQueryFetchOptions & {
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
refetchOnWindowFocus?: boolean;
|
|
29
|
+
refetchOnReconnect?: boolean;
|
|
30
|
+
};
|
|
31
|
+
type UseServerQueryResult<TData> = {
|
|
32
|
+
data: TData | undefined;
|
|
33
|
+
error: Error | null;
|
|
34
|
+
status: FarmClientCacheStatus;
|
|
35
|
+
pending: boolean;
|
|
36
|
+
fetching: boolean;
|
|
37
|
+
stale: boolean;
|
|
38
|
+
refetch: () => Promise<TData>;
|
|
39
|
+
};
|
|
40
|
+
type FarmServerQueryActionInvocation = {
|
|
41
|
+
actionId: string;
|
|
42
|
+
args: readonly unknown[];
|
|
43
|
+
provisionalKey?: string;
|
|
44
|
+
};
|
|
45
|
+
declare function beginFarmServerQueryAction(actionId: string, args: readonly unknown[]): FarmServerQueryActionInvocation;
|
|
46
|
+
declare function completeFarmServerQueryAction<TData>(invocation: FarmServerQueryActionInvocation, value: TData | FarmServerQueryResult<TData>): TData;
|
|
47
|
+
declare function fetchServerQuery<TInput, TData>(query: ServerQuery<TInput, TData>, input: TInput, options?: ServerQueryFetchOptions): Promise<TData>;
|
|
48
|
+
declare function prefetchServerQuery<TInput, TData>(query: ServerQuery<TInput, TData>, input: TInput, options?: Omit<ServerQueryFetchOptions, "force">): Promise<TData>;
|
|
49
|
+
declare function useServerQuery<TInput, TData>(query: ServerQuery<TInput, TData>, input: TInput, options?: UseServerQueryOptions): UseServerQueryResult<TData>;
|
|
50
|
+
|
|
51
|
+
export { type FarmServerQueryActionInvocation, type ServerQueryFetchOptions, type UseServerQueryOptions, type UseServerQueryResult, beginFarmServerQueryAction, completeFarmServerQueryAction, fetchServerQuery, prefetchServerQuery, useServerQuery };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RouteDataCacheKey } from './cache.mjs';
|
|
2
|
+
import { ServerFnContext, ServerFnSchema, AnyServerFnMiddleware, InferServerFnSchemaOutput, ServerFnMiddlewareContext, ServerFnHandler, InferServerFnSchemaInput } from './server-fn.mjs';
|
|
3
|
+
import './server-fn-error-DDh14a0V.mjs';
|
|
4
|
+
|
|
5
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
6
|
+
type ServerQueryStaleTime = number | false | `${number}${"ms" | "s" | "m" | "h"}`;
|
|
7
|
+
type ServerQueryKey<TInput, TContext extends object = {}> = (context: ServerFnContext<TInput, TContext>) => MaybePromise<RouteDataCacheKey>;
|
|
8
|
+
type ServerQueryOptions<TSchema extends ServerFnSchema | undefined, TResult, TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []> = {
|
|
9
|
+
input?: TSchema;
|
|
10
|
+
output?: undefined;
|
|
11
|
+
middleware?: TMiddlewares;
|
|
12
|
+
key: ServerQueryKey<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
13
|
+
/** Milliseconds, a duration string such as "30s", or false for no expiry. */
|
|
14
|
+
staleTime?: ServerQueryStaleTime;
|
|
15
|
+
handler: ServerFnHandler<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, TResult, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
16
|
+
};
|
|
17
|
+
type ServerQueryOutputOptions<TInputSchema extends ServerFnSchema | undefined, TOutputSchema extends ServerFnSchema, TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []> = {
|
|
18
|
+
input?: TInputSchema;
|
|
19
|
+
output: TOutputSchema;
|
|
20
|
+
middleware?: TMiddlewares;
|
|
21
|
+
key: ServerQueryKey<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
22
|
+
/** Milliseconds, a duration string such as "30s", or false for no expiry. */
|
|
23
|
+
staleTime?: ServerQueryStaleTime;
|
|
24
|
+
handler: ServerFnHandler<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, unknown, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
25
|
+
};
|
|
26
|
+
type ServerQuery<TInput, TResult> = ([unknown] extends [TInput] ? (input?: TInput) => Promise<TResult> : (input: TInput) => Promise<TResult>) & {
|
|
27
|
+
readonly __farmServerQuery: true;
|
|
28
|
+
readonly __farmServerQueryInput?: unknown;
|
|
29
|
+
readonly __farmServerQueryOutput?: unknown;
|
|
30
|
+
};
|
|
31
|
+
declare const FARM_SERVER_QUERY_SYMBOL: unique symbol;
|
|
32
|
+
declare function createServerQuery<TInputSchema extends ServerFnSchema, TOutputSchema extends ServerFnSchema, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []>(options: ServerQueryOutputOptions<TInputSchema, TOutputSchema, TMiddlewares>): ServerQuery<InferServerFnSchemaInput<TInputSchema>, Awaited<InferServerFnSchemaOutput<TOutputSchema>>>;
|
|
33
|
+
declare function createServerQuery<TOutputSchema extends ServerFnSchema, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []>(options: ServerQueryOutputOptions<undefined, TOutputSchema, TMiddlewares>): ServerQuery<unknown, Awaited<InferServerFnSchemaOutput<TOutputSchema>>>;
|
|
34
|
+
declare function createServerQuery<TSchema extends ServerFnSchema, TResult, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []>(options: ServerQueryOptions<TSchema, TResult, TMiddlewares>): ServerQuery<InferServerFnSchemaInput<TSchema>, Awaited<TResult>>;
|
|
35
|
+
declare function createServerQuery<TResult, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []>(options: ServerQueryOptions<undefined, TResult, TMiddlewares>): ServerQuery<unknown, Awaited<TResult>>;
|
|
36
|
+
|
|
37
|
+
export { FARM_SERVER_QUERY_SYMBOL, type ServerQuery, type ServerQueryKey, type ServerQueryOptions, type ServerQueryOutputOptions, type ServerQueryStaleTime, createServerQuery };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RouteDataCacheKey } from './cache.js';
|
|
2
|
+
import { ServerFnContext, ServerFnSchema, AnyServerFnMiddleware, InferServerFnSchemaOutput, ServerFnMiddlewareContext, ServerFnHandler, InferServerFnSchemaInput } from './server-fn.js';
|
|
3
|
+
import './server-fn-error-DDh14a0V.js';
|
|
4
|
+
|
|
5
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
6
|
+
type ServerQueryStaleTime = number | false | `${number}${"ms" | "s" | "m" | "h"}`;
|
|
7
|
+
type ServerQueryKey<TInput, TContext extends object = {}> = (context: ServerFnContext<TInput, TContext>) => MaybePromise<RouteDataCacheKey>;
|
|
8
|
+
type ServerQueryOptions<TSchema extends ServerFnSchema | undefined, TResult, TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []> = {
|
|
9
|
+
input?: TSchema;
|
|
10
|
+
output?: undefined;
|
|
11
|
+
middleware?: TMiddlewares;
|
|
12
|
+
key: ServerQueryKey<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
13
|
+
/** Milliseconds, a duration string such as "30s", or false for no expiry. */
|
|
14
|
+
staleTime?: ServerQueryStaleTime;
|
|
15
|
+
handler: ServerFnHandler<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, TResult, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
16
|
+
};
|
|
17
|
+
type ServerQueryOutputOptions<TInputSchema extends ServerFnSchema | undefined, TOutputSchema extends ServerFnSchema, TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []> = {
|
|
18
|
+
input?: TInputSchema;
|
|
19
|
+
output: TOutputSchema;
|
|
20
|
+
middleware?: TMiddlewares;
|
|
21
|
+
key: ServerQueryKey<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
22
|
+
/** Milliseconds, a duration string such as "30s", or false for no expiry. */
|
|
23
|
+
staleTime?: ServerQueryStaleTime;
|
|
24
|
+
handler: ServerFnHandler<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, unknown, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
25
|
+
};
|
|
26
|
+
type ServerQuery<TInput, TResult> = ([unknown] extends [TInput] ? (input?: TInput) => Promise<TResult> : (input: TInput) => Promise<TResult>) & {
|
|
27
|
+
readonly __farmServerQuery: true;
|
|
28
|
+
readonly __farmServerQueryInput?: unknown;
|
|
29
|
+
readonly __farmServerQueryOutput?: unknown;
|
|
30
|
+
};
|
|
31
|
+
declare const FARM_SERVER_QUERY_SYMBOL: unique symbol;
|
|
32
|
+
declare function createServerQuery<TInputSchema extends ServerFnSchema, TOutputSchema extends ServerFnSchema, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []>(options: ServerQueryOutputOptions<TInputSchema, TOutputSchema, TMiddlewares>): ServerQuery<InferServerFnSchemaInput<TInputSchema>, Awaited<InferServerFnSchemaOutput<TOutputSchema>>>;
|
|
33
|
+
declare function createServerQuery<TOutputSchema extends ServerFnSchema, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []>(options: ServerQueryOutputOptions<undefined, TOutputSchema, TMiddlewares>): ServerQuery<unknown, Awaited<InferServerFnSchemaOutput<TOutputSchema>>>;
|
|
34
|
+
declare function createServerQuery<TSchema extends ServerFnSchema, TResult, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []>(options: ServerQueryOptions<TSchema, TResult, TMiddlewares>): ServerQuery<InferServerFnSchemaInput<TSchema>, Awaited<TResult>>;
|
|
35
|
+
declare function createServerQuery<TResult, const TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []>(options: ServerQueryOptions<undefined, TResult, TMiddlewares>): ServerQuery<unknown, Awaited<TResult>>;
|
|
36
|
+
|
|
37
|
+
export { FARM_SERVER_QUERY_SYMBOL, type ServerQuery, type ServerQueryKey, type ServerQueryOptions, type ServerQueryOutputOptions, type ServerQueryStaleTime, createServerQuery };
|
package/dist/server.cjs
CHANGED
|
@@ -23494,6 +23494,15 @@ __name(normalizeMiddlewareModule, "normalizeMiddlewareModule");
|
|
|
23494
23494
|
|
|
23495
23495
|
// src/middleware/manager.ts
|
|
23496
23496
|
init_response();
|
|
23497
|
+
|
|
23498
|
+
// src/cli-colors.ts
|
|
23499
|
+
var import_picocolors = __toESM(require("picocolors"));
|
|
23500
|
+
function createCliColors(interactive = process.stdout.isTTY === true) {
|
|
23501
|
+
return import_picocolors.default.createColors(interactive);
|
|
23502
|
+
}
|
|
23503
|
+
__name(createCliColors, "createCliColors");
|
|
23504
|
+
|
|
23505
|
+
// src/middleware/manager.ts
|
|
23497
23506
|
function isMiddlewareResponse(value) {
|
|
23498
23507
|
return value instanceof Response;
|
|
23499
23508
|
}
|
|
@@ -23650,23 +23659,16 @@ var _MiddlewareManager = class _MiddlewareManager {
|
|
|
23650
23659
|
if (applicable.length === 0) {
|
|
23651
23660
|
return false;
|
|
23652
23661
|
}
|
|
23653
|
-
|
|
23654
|
-
|
|
23655
|
-
|
|
23656
|
-
|
|
23657
|
-
|
|
23658
|
-
|
|
23659
|
-
|
|
23660
|
-
|
|
23661
|
-
|
|
23662
|
-
|
|
23663
|
-
].join(" ");
|
|
23664
|
-
console.log(log);
|
|
23665
|
-
} catch {
|
|
23666
|
-
console.log(
|
|
23667
|
-
`[FARM] [MIDDLEWARE] [${method}] Executing ${pathname} (${applicable.length} middleware)`
|
|
23668
|
-
);
|
|
23669
|
-
}
|
|
23662
|
+
const pc = createCliColors();
|
|
23663
|
+
const log = [
|
|
23664
|
+
pc.dim("[") + pc.bold(pc.blue("FARM")) + pc.dim("]"),
|
|
23665
|
+
pc.dim("[") + pc.bold(pc.magenta("MIDDLEWARE")) + pc.dim("]"),
|
|
23666
|
+
pc.dim("[") + pc.bold(pc.white(method.padEnd(3))) + pc.dim("]"),
|
|
23667
|
+
pc.gray("Executing middleware: "),
|
|
23668
|
+
pc.gray(pathname),
|
|
23669
|
+
pc.dim(` (${(Date.now() - startTime).toFixed(2)}ms)`)
|
|
23670
|
+
].join(" ");
|
|
23671
|
+
console.log(log);
|
|
23670
23672
|
for (const entry of applicable) {
|
|
23671
23673
|
const { mw, routeMatch } = entry;
|
|
23672
23674
|
const configMatch = mw.config ? this.matchesConfig(routePathname, mw.config, ctx) : { matched: true };
|
|
@@ -24902,7 +24904,7 @@ function transformError(id, message) {
|
|
|
24902
24904
|
__name(transformError, "transformError");
|
|
24903
24905
|
|
|
24904
24906
|
// package.json
|
|
24905
|
-
var version = "0.1.0-beta.
|
|
24907
|
+
var version = "0.1.0-beta.22";
|
|
24906
24908
|
|
|
24907
24909
|
// src/version.ts
|
|
24908
24910
|
var FARM_VERSION = version;
|
|
@@ -25607,18 +25609,14 @@ function farmPlugin(options = {}, initialPluginManager) {
|
|
|
25607
25609
|
let refreshRouteDiscovery = null;
|
|
25608
25610
|
let workflowHandler = null;
|
|
25609
25611
|
const logUpdate = /* @__PURE__ */ __name((tag, message) => {
|
|
25610
|
-
|
|
25611
|
-
|
|
25612
|
-
|
|
25613
|
-
|
|
25614
|
-
|
|
25615
|
-
|
|
25616
|
-
|
|
25617
|
-
|
|
25618
|
-
console.log(log);
|
|
25619
|
-
} catch {
|
|
25620
|
-
console.log(`[FARM] [${tag}] [UPDATE] ${message}`);
|
|
25621
|
-
}
|
|
25612
|
+
const pc = createCliColors();
|
|
25613
|
+
const log = [
|
|
25614
|
+
pc.dim("[") + pc.bold(pc.blue("FARM")) + pc.dim("]"),
|
|
25615
|
+
pc.dim("[") + pc.bold(pc.cyan(tag)) + pc.dim("]"),
|
|
25616
|
+
pc.dim("[") + pc.bold(pc.yellow("UPDATE")) + pc.dim("]"),
|
|
25617
|
+
pc.gray(message)
|
|
25618
|
+
].join(" ");
|
|
25619
|
+
console.log(log);
|
|
25622
25620
|
}, "logUpdate");
|
|
25623
25621
|
return {
|
|
25624
25622
|
name: "farm",
|
|
@@ -26059,25 +26057,21 @@ window.__FARM_MANIFEST__ = ${inlineValue({
|
|
|
26059
26057
|
return;
|
|
26060
26058
|
}
|
|
26061
26059
|
logResponse.__last = { key: dedupeKey, ts: now };
|
|
26062
|
-
|
|
26063
|
-
|
|
26064
|
-
|
|
26065
|
-
|
|
26066
|
-
|
|
26067
|
-
|
|
26068
|
-
|
|
26069
|
-
|
|
26070
|
-
|
|
26071
|
-
|
|
26072
|
-
|
|
26073
|
-
|
|
26074
|
-
|
|
26075
|
-
|
|
26076
|
-
|
|
26077
|
-
console.log(log);
|
|
26078
|
-
} catch {
|
|
26079
|
-
console.log(`[FARM] [${tag}] [${method}] ${urlPath} - ${status} (${duration}ms)`);
|
|
26080
|
-
}
|
|
26060
|
+
const pc = createCliColors();
|
|
26061
|
+
let statusColor = pc.green;
|
|
26062
|
+
if (status >= 500) statusColor = pc.red;
|
|
26063
|
+
else if (status >= 400) statusColor = pc.yellow;
|
|
26064
|
+
else if (status >= 300) statusColor = pc.cyan;
|
|
26065
|
+
const log = [
|
|
26066
|
+
pc.dim("[") + pc.bold(pc.blue("FARM")) + pc.dim("]"),
|
|
26067
|
+
pc.dim("[") + pc.bold(pc.cyan(tag)) + pc.dim("]"),
|
|
26068
|
+
pc.dim("[") + pc.bold(pc.white(method.padEnd(3))) + pc.dim("]"),
|
|
26069
|
+
pc.gray(urlPath),
|
|
26070
|
+
pc.dim("-"),
|
|
26071
|
+
statusColor(status.toString()),
|
|
26072
|
+
pc.dim(`(${duration}ms)`)
|
|
26073
|
+
].join(" ");
|
|
26074
|
+
console.log(log);
|
|
26081
26075
|
}, "logResponse");
|
|
26082
26076
|
server.middlewares.use(
|
|
26083
26077
|
_withAfterNodeMiddleware(async (req, res, next) => {
|
|
@@ -29143,7 +29137,7 @@ async function defineConfig2(config = {}) {
|
|
|
29143
29137
|
return null;
|
|
29144
29138
|
}
|
|
29145
29139
|
};
|
|
29146
|
-
const pc =
|
|
29140
|
+
const pc = createCliColors();
|
|
29147
29141
|
let serverStarted = false;
|
|
29148
29142
|
let startTime = Date.now();
|
|
29149
29143
|
const farmLogger = {
|
|
@@ -30524,22 +30518,6 @@ var DEFAULT_FARM_DEV_SERVER_PORT = 3e3;
|
|
|
30524
30518
|
function createBrandingPlugin() {
|
|
30525
30519
|
let serverStarted = false;
|
|
30526
30520
|
let startTime = Date.now();
|
|
30527
|
-
const getColors = /* @__PURE__ */ __name(() => {
|
|
30528
|
-
const id = /* @__PURE__ */ __name((s) => s, "id");
|
|
30529
|
-
try {
|
|
30530
|
-
const pc = typeof require === "function" ? require("picocolors") : null;
|
|
30531
|
-
if (pc && typeof pc.createColors === "function") return pc.createColors(true);
|
|
30532
|
-
if (pc) return pc;
|
|
30533
|
-
} catch {
|
|
30534
|
-
}
|
|
30535
|
-
return {
|
|
30536
|
-
dim: id,
|
|
30537
|
-
bold: id,
|
|
30538
|
-
green: id,
|
|
30539
|
-
cyan: id,
|
|
30540
|
-
gray: id
|
|
30541
|
-
};
|
|
30542
|
-
}, "getColors");
|
|
30543
30521
|
return {
|
|
30544
30522
|
name: "farm:branding",
|
|
30545
30523
|
enforce: "pre",
|
|
@@ -30553,7 +30531,7 @@ function createBrandingPlugin() {
|
|
|
30553
30531
|
const elapsed = Date.now() - startTime;
|
|
30554
30532
|
const address = server.httpServer?.address();
|
|
30555
30533
|
const resolvedPort = typeof address === "object" && address ? address.port : server.config.server.port || port || 3e3;
|
|
30556
|
-
const pc =
|
|
30534
|
+
const pc = createCliColors();
|
|
30557
30535
|
console.log("");
|
|
30558
30536
|
console.log(
|
|
30559
30537
|
` ${pc.bold(pc.green("Farm.js"))} ${pc.dim(`v${FARM_VERSION}`)} ${pc.dim(`ready in ${elapsed}ms`)}`
|