@farm.js/core 0.1.0-beta.21 → 0.1.0-beta.23
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 +97 -0
- package/dist/agent-runtime.d.ts +97 -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-CTFnOJaI.d.ts +308 -0
- package/dist/app-DA6ospIq.d.mts +308 -0
- package/dist/app-markdown.d.mts +25 -0
- package/dist/app-markdown.d.ts +25 -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-4IVNW5QD.mjs +82 -0
- package/dist/chunk-4IVNW5QD.mjs.map +1 -0
- package/dist/{chunk-I3UWA2P2.mjs → chunk-5NOVWCFL.mjs} +2 -2
- package/dist/chunk-5NOVWCFL.mjs.map +1 -0
- package/dist/chunk-D42BNPZH.mjs +79 -0
- package/dist/chunk-D42BNPZH.mjs.map +1 -0
- package/dist/{chunk-LLPN5SEZ.mjs → chunk-DVPRBMU2.mjs} +2 -2
- package/dist/{chunk-VIC7NJ77.mjs → chunk-FJGTYLCO.mjs} +67 -20
- package/dist/chunk-FJGTYLCO.mjs.map +1 -0
- package/dist/chunk-GIELMNBG.mjs +15 -0
- package/dist/chunk-GIELMNBG.mjs.map +1 -0
- package/dist/chunk-GQVQESLY.mjs +25 -0
- package/dist/chunk-GQVQESLY.mjs.map +1 -0
- package/dist/chunk-H53KVQUU.mjs +48 -0
- package/dist/chunk-H53KVQUU.mjs.map +1 -0
- package/dist/chunk-HCGQYYHI.mjs +1 -0
- package/dist/chunk-HCGQYYHI.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-UCYWGN2P.mjs → chunk-OHNSROHS.mjs} +1 -1
- package/dist/{chunk-FRPWCMMG.mjs → chunk-SBWOTAX4.mjs} +63 -2
- package/dist/chunk-SBWOTAX4.mjs.map +1 -0
- package/dist/{chunk-FKKM7HVF.mjs → chunk-TX54PXAJ.mjs} +109 -58
- package/dist/chunk-TX54PXAJ.mjs.map +1 -0
- package/dist/{chunk-CEVMYGDL.mjs → chunk-YD5IRKVS.mjs} +13 -9
- package/dist/chunk-YD5IRKVS.mjs.map +1 -0
- 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-CCilIb_G.d.mts +2092 -0
- package/dist/client-plugins-DuuleQKk.d.ts +2092 -0
- package/dist/client-plugins.d.mts +25 -0
- package/dist/client-plugins.d.ts +25 -0
- package/dist/client.cjs +122 -35
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.mts +454 -0
- package/dist/client.d.ts +454 -0
- package/dist/client.mjs +13 -2
- package/dist/config.d.mts +32 -0
- package/dist/config.d.ts +32 -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/{devtools-52FYXIEK.mjs → devtools-326RBQCN.mjs} +7 -6
- package/dist/{devtools-52FYXIEK.mjs.map → devtools-326RBQCN.mjs.map} +1 -1
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.d.mts +80 -0
- package/dist/docs.d.ts +80 -0
- package/dist/docs.mjs +6 -5
- 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 +496 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +480 -0
- package/dist/index.d.ts +480 -0
- package/dist/index.mjs +70 -52
- 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 +25 -0
- package/dist/integrations.d.ts +25 -0
- package/dist/internal/build-runtime.cjs +386 -83
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.d.mts +42 -0
- package/dist/internal/build-runtime.d.ts +42 -0
- package/dist/internal/build-runtime.mjs +17 -13
- package/dist/internal/client-runtime.d.mts +17 -0
- package/dist/internal/client-runtime.d.ts +17 -0
- package/dist/internal/config-runtime.cjs +41 -0
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +42 -0
- package/dist/internal/config-runtime.d.ts +42 -0
- package/dist/internal/config-runtime.mjs +5 -4
- 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.cjs +178 -0
- package/dist/internal/production-runtime.cjs.map +1 -1
- package/dist/internal/production-runtime.d.mts +80 -0
- package/dist/internal/production-runtime.d.ts +80 -0
- package/dist/internal/production-runtime.mjs +13 -1
- package/dist/internal/production-runtime.mjs.map +1 -1
- 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-DyPRG0wX.d.ts +22 -0
- package/dist/metadata-_GHcAySx.d.mts +22 -0
- package/dist/middleware.cjs +17 -17
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.mts +172 -0
- package/dist/middleware.d.ts +172 -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 +261 -62
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +25 -0
- package/dist/plugin.d.ts +25 -0
- package/dist/plugin.mjs +13 -9
- package/dist/production-runtime-C4cO3esK.d.mts +81 -0
- package/dist/production-runtime-DrEy8kBO.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-B2PpOxYK.d.mts +6 -0
- package/dist/request-D40lt6aN.d.ts +6 -0
- package/dist/request.d.mts +26 -0
- package/dist/request.d.ts +26 -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 +227 -0
- package/dist/routes.d.ts +227 -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 +58 -0
- package/dist/server-plugins.d.ts +58 -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 +285 -85
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +53 -0
- package/dist/server.d.ts +53 -0
- package/dist/server.mjs +26 -31
- 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 +104 -0
- package/dist/testing.d.ts +104 -0
- package/dist/theme/client.cjs +115 -0
- package/dist/theme/client.cjs.map +1 -0
- package/dist/theme/client.d.mts +17 -0
- package/dist/theme/client.d.ts +17 -0
- package/dist/theme/client.mjs +16 -0
- package/dist/theme/client.mjs.map +1 -0
- package/dist/theme/index.cjs +71 -0
- package/dist/theme/index.cjs.map +1 -0
- package/dist/theme/index.d.mts +6 -0
- package/dist/theme/index.d.ts +6 -0
- package/dist/theme/index.mjs +9 -0
- package/dist/theme/index.mjs.map +1 -0
- package/dist/theme/server.cjs +191 -0
- package/dist/theme/server.cjs.map +1 -0
- package/dist/theme/server.d.mts +8 -0
- package/dist/theme/server.d.ts +8 -0
- package/dist/theme/server.mjs +18 -0
- package/dist/theme/server.mjs.map +1 -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-CsR8fpgF.d.mts +30 -0
- package/dist/types-CsR8fpgF.d.ts +30 -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-3sQgfkya.d.ts +23 -0
- package/dist/utils-Bop7bly-.d.mts +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 +285 -64
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +25 -0
- package/dist/vite.d.ts +25 -0
- package/dist/vite.mjs +13 -9
- 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 +25 -1
- package/dist/chunk-4EATUJFO.mjs.map +0 -1
- package/dist/chunk-CEVMYGDL.mjs.map +0 -1
- package/dist/chunk-FKKM7HVF.mjs.map +0 -1
- package/dist/chunk-FRPWCMMG.mjs.map +0 -1
- package/dist/chunk-I3UWA2P2.mjs.map +0 -1
- package/dist/chunk-MIUW47JX.mjs.map +0 -1
- package/dist/chunk-VIC7NJ77.mjs.map +0 -1
- /package/dist/{chunk-RIXKJPGI.mjs.map → chunk-42325TLU.mjs.map} +0 -0
- /package/dist/{chunk-LLPN5SEZ.mjs.map → chunk-DVPRBMU2.mjs.map} +0 -0
- /package/dist/{chunk-UCYWGN2P.mjs.map → chunk-OHNSROHS.mjs.map} +0 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { FarmCacheInvalidationTarget } from './cache.mjs';
|
|
2
|
+
import { M as MultipartSchema, T as TypedFormData } from './transport-BmbGTXA5.mjs';
|
|
3
|
+
|
|
4
|
+
type AnySchema = {
|
|
5
|
+
_output?: any;
|
|
6
|
+
_input?: any;
|
|
7
|
+
parse?: (data: unknown) => any;
|
|
8
|
+
};
|
|
9
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
10
|
+
type Simplify<T> = {
|
|
11
|
+
[TKey in keyof T]: T[TKey];
|
|
12
|
+
} & {};
|
|
13
|
+
type UnionToIntersection<T> = (T extends unknown ? (value: T) => void : never) extends (value: infer TIntersection) => void ? TIntersection : never;
|
|
14
|
+
type InferOutput<T> = T extends {
|
|
15
|
+
_output: infer O;
|
|
16
|
+
} ? O : T extends {
|
|
17
|
+
parse: (data: unknown) => infer R;
|
|
18
|
+
} ? R : unknown;
|
|
19
|
+
type InferInput<T> = T extends {
|
|
20
|
+
_input: infer I;
|
|
21
|
+
} ? I : T extends {
|
|
22
|
+
parse: (data: infer I) => unknown;
|
|
23
|
+
} ? I : unknown;
|
|
24
|
+
type InferBodyInput<T> = T extends MultipartSchema<AnySchema> ? TypedFormData<InferOutput<T>> : InferOutput<T>;
|
|
25
|
+
type InferHeadersOutput<T> = [T] extends [never] ? Record<string, string> : T extends AnySchema ? InferOutput<T> : Record<string, string>;
|
|
26
|
+
type EndpointErrorSchema = AnySchema & {
|
|
27
|
+
parse: (data: unknown) => unknown;
|
|
28
|
+
};
|
|
29
|
+
type EndpointErrorDefinitionBase<TStatus extends number> = {
|
|
30
|
+
status: TStatus;
|
|
31
|
+
/** Public message safe to expose to API callers. */
|
|
32
|
+
message?: string;
|
|
33
|
+
};
|
|
34
|
+
type EndpointErrorDefinition<TSchema extends EndpointErrorSchema = EndpointErrorSchema, TStatus extends number = number> = EndpointErrorDefinitionBase<TStatus> & ({
|
|
35
|
+
/** Schema for the public error payload exposed to API callers. */
|
|
36
|
+
data: TSchema;
|
|
37
|
+
schema?: never;
|
|
38
|
+
} | {
|
|
39
|
+
data?: never;
|
|
40
|
+
/** @deprecated Use `data` for consistency with server functions. */
|
|
41
|
+
schema: TSchema;
|
|
42
|
+
});
|
|
43
|
+
type EndpointErrorDefinitions = Record<string, EndpointErrorDefinition<EndpointErrorSchema, number>>;
|
|
44
|
+
type InferEndpointErrorSchema<TDefinition> = TDefinition extends {
|
|
45
|
+
data: infer TSchema extends AnySchema;
|
|
46
|
+
} ? TSchema : TDefinition extends {
|
|
47
|
+
schema: infer TSchema extends AnySchema;
|
|
48
|
+
} ? TSchema : never;
|
|
49
|
+
type EndpointErrorContracts<TErrors extends EndpointErrorDefinitions> = {
|
|
50
|
+
[TCode in keyof TErrors]: {
|
|
51
|
+
data: InferOutput<InferEndpointErrorSchema<TErrors[TCode]>>;
|
|
52
|
+
status: TErrors[TCode]["status"];
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type EndpointErrorHandler<TErrors extends EndpointErrorDefinitions> = <TCode extends keyof TErrors & string>(code: TCode, data: InferInput<InferEndpointErrorSchema<TErrors[TCode]>>) => never;
|
|
56
|
+
/** @deprecated Use `EndpointErrorHandler`. */
|
|
57
|
+
type EndpointFail<TErrors extends EndpointErrorDefinitions> = EndpointErrorHandler<TErrors>;
|
|
58
|
+
declare class EndpointFailure<TCode extends string = string, TData = unknown> extends Error {
|
|
59
|
+
readonly code: TCode;
|
|
60
|
+
readonly data: TData;
|
|
61
|
+
readonly status: number;
|
|
62
|
+
constructor(code: TCode, data: TData, options: {
|
|
63
|
+
status: number;
|
|
64
|
+
message: string;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
declare function isEndpointFailure(value: unknown): value is EndpointFailure<string, unknown>;
|
|
68
|
+
type EndpointParamValue = string | string[];
|
|
69
|
+
type EndpointParams = Record<string, EndpointParamValue>;
|
|
70
|
+
type EndpointMiddlewareContext<TContext extends object = {}, TBody = unknown, TQuery = unknown, THeaders = Record<string, string>> = {
|
|
71
|
+
body: TBody;
|
|
72
|
+
query: TQuery;
|
|
73
|
+
headers: THeaders;
|
|
74
|
+
request: Request;
|
|
75
|
+
/** Context accumulated from middleware that ran earlier in the chain. */
|
|
76
|
+
context: Readonly<TContext>;
|
|
77
|
+
params: EndpointParams;
|
|
78
|
+
};
|
|
79
|
+
type EndpointMiddlewareResult<TProvidedContext extends object = object> = TProvidedContext | true | false | Response;
|
|
80
|
+
/** A plain async function. No wrapper or `next()` callback is required. */
|
|
81
|
+
type EndpointMiddleware<TProvidedContext extends object = object, TContext extends object = {}, TBody = unknown, TQuery = unknown, THeaders = Record<string, string>> = (ctx: EndpointMiddlewareContext<TContext, TBody, TQuery, THeaders>) => MaybePromise<EndpointMiddlewareResult<TProvidedContext>>;
|
|
82
|
+
type AnyEndpointMiddleware = (ctx: EndpointMiddlewareContext<any, any, any, any>) => unknown;
|
|
83
|
+
type EndpointInvalidationTarget = FarmCacheInvalidationTarget;
|
|
84
|
+
type EndpointInvalidationContext<TContext extends object = {}, TBody = unknown, TQuery = unknown, THeaders = Record<string, string>> = EndpointMiddlewareContext<TContext, TBody, TQuery, THeaders> & {
|
|
85
|
+
/** The raw value returned by the endpoint handler. */
|
|
86
|
+
result: unknown;
|
|
87
|
+
};
|
|
88
|
+
type EndpointInvalidations<TContext extends object = {}, TBody = unknown, TQuery = unknown, THeaders = Record<string, string>> = readonly EndpointInvalidationTarget[] | ((context: EndpointInvalidationContext<TContext, TBody, TQuery, THeaders>) => readonly EndpointInvalidationTarget[] | Promise<readonly EndpointInvalidationTarget[]>);
|
|
89
|
+
type ValidateEndpointMiddlewares<TMiddlewares extends readonly AnyEndpointMiddleware[]> = {
|
|
90
|
+
readonly [TIndex in keyof TMiddlewares]: TMiddlewares[TIndex] extends AnyEndpointMiddleware ? [Awaited<ReturnType<TMiddlewares[TIndex]>>] extends [EndpointMiddlewareResult<object>] ? TMiddlewares[TIndex] : never : never;
|
|
91
|
+
};
|
|
92
|
+
type ContextFromMiddlewareResult<TResult> = Exclude<TResult, Response | boolean> extends infer TContext ? [TContext] extends [never] ? {} : TContext extends object ? TContext : {} : {};
|
|
93
|
+
type ContextFromMiddleware<TMiddleware> = TMiddleware extends (...args: any[]) => infer TResult ? ContextFromMiddlewareResult<Awaited<TResult>> : {};
|
|
94
|
+
type InferEndpointMiddlewareContext<TMiddlewares extends readonly ((...args: any[]) => any)[], TContext extends object = {}> = TMiddlewares extends readonly [infer TMiddleware, ...infer TRest] ? TMiddleware extends (...args: any[]) => any ? TRest extends readonly ((...args: any[]) => any)[] ? InferEndpointMiddlewareContext<TRest, Simplify<TContext & ContextFromMiddleware<TMiddleware>>> : Simplify<TContext> : Simplify<TContext> : number extends TMiddlewares["length"] ? Simplify<TContext & UnionToIntersection<ContextFromMiddleware<TMiddlewares[number]>>> : Simplify<TContext>;
|
|
95
|
+
type EndpointOptions<TBody extends AnySchema = never, TQuery extends AnySchema = never, THeaders extends AnySchema = never, TMiddlewares extends readonly AnyEndpointMiddleware[] = readonly [], TErrors extends EndpointErrorDefinitions = {}> = {
|
|
96
|
+
method?: "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
|
|
97
|
+
body?: TBody;
|
|
98
|
+
query?: TQuery;
|
|
99
|
+
headers?: THeaders;
|
|
100
|
+
middleware?: TMiddlewares;
|
|
101
|
+
/**
|
|
102
|
+
* Cache keys, tags, and route paths made stale after a successful handler result.
|
|
103
|
+
* The resolver receives validated input and middleware context.
|
|
104
|
+
*/
|
|
105
|
+
invalidates?: EndpointInvalidations<InferEndpointMiddlewareContext<TMiddlewares>, InferOutput<TBody>, InferOutput<TQuery>, InferHeadersOutput<THeaders>>;
|
|
106
|
+
errors?: TErrors;
|
|
107
|
+
/** @deprecated Use plain functions in `middleware` for Farm endpoint middleware. */
|
|
108
|
+
use?: any[];
|
|
109
|
+
};
|
|
110
|
+
type EndpointHandler<TBody extends AnySchema = never, TQuery extends AnySchema = never, THeaders extends AnySchema = never, TResponse = any, TContext extends object = {}, TErrors extends EndpointErrorDefinitions = {}> = (ctx: {
|
|
111
|
+
body: InferOutput<TBody>;
|
|
112
|
+
query: InferOutput<TQuery>;
|
|
113
|
+
headers: InferHeadersOutput<THeaders>;
|
|
114
|
+
request: Request;
|
|
115
|
+
context: Readonly<TContext>;
|
|
116
|
+
params: EndpointParams;
|
|
117
|
+
error: EndpointErrorHandler<TErrors>;
|
|
118
|
+
/** @deprecated Use `error`. */
|
|
119
|
+
fail: EndpointFail<TErrors>;
|
|
120
|
+
}) => Promise<TResponse> | TResponse;
|
|
121
|
+
type TypedEndpoint<TBody = never, TQuery = never, TResponse = any, THeaders = Record<string, string>, TErrors = never, TBodyInput = TBody> = {
|
|
122
|
+
__types: {
|
|
123
|
+
body: TBody;
|
|
124
|
+
inputBody: TBodyInput;
|
|
125
|
+
query: TQuery;
|
|
126
|
+
headers: THeaders;
|
|
127
|
+
response: TResponse;
|
|
128
|
+
errors: TErrors;
|
|
129
|
+
};
|
|
130
|
+
__path?: string;
|
|
131
|
+
__method?: string;
|
|
132
|
+
} & ((options?: {
|
|
133
|
+
body?: TBody;
|
|
134
|
+
query?: TQuery;
|
|
135
|
+
}) => Promise<TResponse>);
|
|
136
|
+
type CreatedEndpoint<TBody extends AnySchema, TQuery extends AnySchema, THeaders extends AnySchema, TResponse, TErrors extends EndpointErrorDefinitions = {}> = TypedEndpoint<InferOutput<TBody>, InferOutput<TQuery>, Awaited<TResponse>, InferHeadersOutput<THeaders>, EndpointErrorContracts<TErrors>, InferBodyInput<TBody>>;
|
|
137
|
+
type AnyEndpointOptions = EndpointOptions<AnySchema, AnySchema, AnySchema, readonly AnyEndpointMiddleware[], EndpointErrorDefinitions>;
|
|
138
|
+
type EndpointBodyFromOptions<TOptions> = TOptions extends {
|
|
139
|
+
body: infer TBody extends AnySchema;
|
|
140
|
+
} ? TBody : never;
|
|
141
|
+
type EndpointQueryFromOptions<TOptions> = TOptions extends {
|
|
142
|
+
query: infer TQuery extends AnySchema;
|
|
143
|
+
} ? TQuery : never;
|
|
144
|
+
type EndpointHeadersFromOptions<TOptions> = TOptions extends {
|
|
145
|
+
headers: infer THeaders extends AnySchema;
|
|
146
|
+
} ? THeaders : never;
|
|
147
|
+
type EndpointMiddlewaresFromOptions<TOptions> = TOptions extends {
|
|
148
|
+
middleware: infer TMiddlewares extends readonly AnyEndpointMiddleware[];
|
|
149
|
+
} ? TMiddlewares : readonly [];
|
|
150
|
+
type EndpointErrorsFromOptions<TOptions> = TOptions extends {
|
|
151
|
+
errors: infer TErrors extends EndpointErrorDefinitions;
|
|
152
|
+
} ? TErrors : {};
|
|
153
|
+
type MethodlessEndpointOptions = Omit<AnyEndpointOptions, "method">;
|
|
154
|
+
type EndpointHandlerFromOptions<TOptions, TResponse> = EndpointHandler<EndpointBodyFromOptions<TOptions>, EndpointQueryFromOptions<TOptions>, EndpointHeadersFromOptions<TOptions>, TResponse, InferEndpointMiddlewareContext<EndpointMiddlewaresFromOptions<TOptions>>, EndpointErrorsFromOptions<TOptions>>;
|
|
155
|
+
type ValidatedEndpointHandlerFromOptions<TOptions, TResponse> = EndpointHandlerFromOptions<TOptions, TResponse> & (EndpointMiddlewaresFromOptions<TOptions> extends ValidateEndpointMiddlewares<EndpointMiddlewaresFromOptions<TOptions>> ? unknown : never);
|
|
156
|
+
type CreatedEndpointFromOptions<TOptions, TResponse> = CreatedEndpoint<EndpointBodyFromOptions<TOptions>, EndpointQueryFromOptions<TOptions>, EndpointHeadersFromOptions<TOptions>, TResponse, EndpointErrorsFromOptions<TOptions>>;
|
|
157
|
+
/**
|
|
158
|
+
* Create a Farm.js API endpoint
|
|
159
|
+
*
|
|
160
|
+
* Supports two patterns:
|
|
161
|
+
* 1. File-based routing (path auto-inferred from file location):
|
|
162
|
+
* `export const POST = createEndpoint({ method: 'POST', body: schema }, handler)`
|
|
163
|
+
* `createEndpoint({ method: 'GET', query: z.object({...}) }, handler)`
|
|
164
|
+
*
|
|
165
|
+
* 2. Explicit path (for routes.ts at project root):
|
|
166
|
+
* `createEndpoint('/api/hello', { method: 'GET', query: z.object({...}) }, handler)`
|
|
167
|
+
*/
|
|
168
|
+
declare function createEndpoint<const TOptions extends AnyEndpointOptions, TResponse = any>(options: TOptions, handler: ValidatedEndpointHandlerFromOptions<TOptions, TResponse>): CreatedEndpointFromOptions<TOptions, TResponse>;
|
|
169
|
+
declare function createEndpoint<const TOptions extends AnyEndpointOptions, TResponse = any>(path: string, options: TOptions, handler: ValidatedEndpointHandlerFromOptions<TOptions, TResponse>): CreatedEndpointFromOptions<TOptions, TResponse>;
|
|
170
|
+
declare function createEndpoint<TBody extends AnySchema = never, TQuery extends AnySchema = never, THeaders extends AnySchema = never, TResponse = any>(options: EndpointOptions<TBody, TQuery, THeaders, readonly []>, handler: EndpointHandler<TBody, TQuery, THeaders, TResponse>): CreatedEndpoint<TBody, TQuery, THeaders, TResponse>;
|
|
171
|
+
declare function createEndpoint<TBody extends AnySchema = never, TQuery extends AnySchema = never, THeaders extends AnySchema = never, TResponse = any>(path: string, options: EndpointOptions<TBody, TQuery, THeaders, readonly []>, handler: EndpointHandler<TBody, TQuery, THeaders, TResponse>): CreatedEndpoint<TBody, TQuery, THeaders, TResponse>;
|
|
172
|
+
/**
|
|
173
|
+
* Convenience method for GET requests
|
|
174
|
+
*/
|
|
175
|
+
declare function GET<T = any>(handler: EndpointHandler<never, never, never, T>): CreatedEndpoint<never, never, never, T>;
|
|
176
|
+
declare function GET<const TOptions extends MethodlessEndpointOptions, TResponse = any>(options: TOptions, handler: ValidatedEndpointHandlerFromOptions<TOptions, TResponse>): CreatedEndpointFromOptions<TOptions, TResponse>;
|
|
177
|
+
declare function GET<TQuery extends AnySchema = never, THeaders extends AnySchema = never, TResponse = any>(options: Omit<EndpointOptions<never, TQuery, THeaders, readonly []>, "method">, handler: EndpointHandler<never, TQuery, THeaders, TResponse>): CreatedEndpoint<never, TQuery, THeaders, TResponse>;
|
|
178
|
+
/**
|
|
179
|
+
* Convenience method for HEAD requests
|
|
180
|
+
*/
|
|
181
|
+
declare function HEAD<T = any>(handler: EndpointHandler<never, never, never, T>): CreatedEndpoint<never, never, never, T>;
|
|
182
|
+
declare function HEAD<const TOptions extends MethodlessEndpointOptions, TResponse = any>(options: TOptions, handler: ValidatedEndpointHandlerFromOptions<TOptions, TResponse>): CreatedEndpointFromOptions<TOptions, TResponse>;
|
|
183
|
+
declare function HEAD<TQuery extends AnySchema = never, THeaders extends AnySchema = never, TResponse = any>(options: Omit<EndpointOptions<never, TQuery, THeaders, readonly []>, "method">, handler: EndpointHandler<never, TQuery, THeaders, TResponse>): CreatedEndpoint<never, TQuery, THeaders, TResponse>;
|
|
184
|
+
/**
|
|
185
|
+
* Convenience method for POST requests
|
|
186
|
+
*/
|
|
187
|
+
declare function POST<T = any>(handler: EndpointHandler<never, never, never, T>): CreatedEndpoint<never, never, never, T>;
|
|
188
|
+
declare function POST<const TOptions extends MethodlessEndpointOptions, TResponse = any>(options: TOptions, handler: ValidatedEndpointHandlerFromOptions<TOptions, TResponse>): CreatedEndpointFromOptions<TOptions, TResponse>;
|
|
189
|
+
declare function POST<TBody extends AnySchema = never, TQuery extends AnySchema = never, THeaders extends AnySchema = never, TResponse = any>(options: Omit<EndpointOptions<TBody, TQuery, THeaders, readonly []>, "method">, handler: EndpointHandler<TBody, TQuery, THeaders, TResponse>): CreatedEndpoint<TBody, TQuery, THeaders, TResponse>;
|
|
190
|
+
/**
|
|
191
|
+
* Convenience method for PUT requests
|
|
192
|
+
*/
|
|
193
|
+
declare function PUT<T = any>(handler: EndpointHandler<never, never, never, T>): CreatedEndpoint<never, never, never, T>;
|
|
194
|
+
declare function PUT<const TOptions extends MethodlessEndpointOptions, TResponse = any>(options: TOptions, handler: ValidatedEndpointHandlerFromOptions<TOptions, TResponse>): CreatedEndpointFromOptions<TOptions, TResponse>;
|
|
195
|
+
declare function PUT<TBody extends AnySchema = never, TQuery extends AnySchema = never, THeaders extends AnySchema = never, TResponse = any>(options: Omit<EndpointOptions<TBody, TQuery, THeaders, readonly []>, "method">, handler: EndpointHandler<TBody, TQuery, THeaders, TResponse>): CreatedEndpoint<TBody, TQuery, THeaders, TResponse>;
|
|
196
|
+
/**
|
|
197
|
+
* Convenience method for DELETE requests
|
|
198
|
+
*/
|
|
199
|
+
declare function DELETE<T = any>(handler: EndpointHandler<never, never, never, T>): CreatedEndpoint<never, never, never, T>;
|
|
200
|
+
declare function DELETE<const TOptions extends MethodlessEndpointOptions, TResponse = any>(options: TOptions, handler: ValidatedEndpointHandlerFromOptions<TOptions, TResponse>): CreatedEndpointFromOptions<TOptions, TResponse>;
|
|
201
|
+
declare function DELETE<TBody extends AnySchema = never, TQuery extends AnySchema = never, THeaders extends AnySchema = never, TResponse = any>(options: Omit<EndpointOptions<TBody, TQuery, THeaders, readonly []>, "method">, handler: EndpointHandler<TBody, TQuery, THeaders, TResponse>): CreatedEndpoint<TBody, TQuery, THeaders, TResponse>;
|
|
202
|
+
/**
|
|
203
|
+
* Convenience method for PATCH requests
|
|
204
|
+
*/
|
|
205
|
+
declare function PATCH<T = any>(handler: EndpointHandler<never, never, never, T>): CreatedEndpoint<never, never, never, T>;
|
|
206
|
+
declare function PATCH<const TOptions extends MethodlessEndpointOptions, TResponse = any>(options: TOptions, handler: ValidatedEndpointHandlerFromOptions<TOptions, TResponse>): CreatedEndpointFromOptions<TOptions, TResponse>;
|
|
207
|
+
declare function PATCH<TBody extends AnySchema = never, TQuery extends AnySchema = never, THeaders extends AnySchema = never, TResponse = any>(options: Omit<EndpointOptions<TBody, TQuery, THeaders, readonly []>, "method">, handler: EndpointHandler<TBody, TQuery, THeaders, TResponse>): CreatedEndpoint<TBody, TQuery, THeaders, TResponse>;
|
|
208
|
+
/**
|
|
209
|
+
* Convenience method for OPTIONS requests
|
|
210
|
+
*/
|
|
211
|
+
declare function OPTIONS<T = any>(handler: EndpointHandler<never, never, never, T>): CreatedEndpoint<never, never, never, T>;
|
|
212
|
+
declare function OPTIONS<const TOptions extends MethodlessEndpointOptions, TResponse = any>(options: TOptions, handler: ValidatedEndpointHandlerFromOptions<TOptions, TResponse>): CreatedEndpointFromOptions<TOptions, TResponse>;
|
|
213
|
+
declare function OPTIONS<TBody extends AnySchema = never, TQuery extends AnySchema = never, THeaders extends AnySchema = never, TResponse = any>(options: Omit<EndpointOptions<TBody, TQuery, THeaders, readonly []>, "method">, handler: EndpointHandler<TBody, TQuery, THeaders, TResponse>): CreatedEndpoint<TBody, TQuery, THeaders, TResponse>;
|
|
214
|
+
|
|
215
|
+
type APIRouteParamValue = string | string[];
|
|
216
|
+
type APIRouteParams = Record<string, APIRouteParamValue>;
|
|
217
|
+
interface APIRouteMatch<T extends {
|
|
218
|
+
path: string;
|
|
219
|
+
}> {
|
|
220
|
+
route: T;
|
|
221
|
+
params: APIRouteParams;
|
|
222
|
+
}
|
|
223
|
+
declare function matchAPIRoute<T extends {
|
|
224
|
+
path: string;
|
|
225
|
+
}>(routes: Map<string, T>, pathname: string): APIRouteMatch<T> | null;
|
|
226
|
+
declare function invokeAPIRouteEndpoint(endpoint: any, request: Request, params?: APIRouteParams, bodySizeLimit?: number): Promise<Response>;
|
|
227
|
+
declare function normalizeRouteResponse(result: unknown): Response;
|
|
228
|
+
declare function isWebResponse(value: unknown): value is Response;
|
|
229
|
+
declare function createEndpointFailureResponse(failure: EndpointFailure<string, unknown>): Response;
|
|
230
|
+
|
|
231
|
+
export { type APIRouteMatch as A, PATCH as B, createEndpointFailureResponse as C, DELETE as D, type EndpointErrorSchema as E, GET as G, HEAD as H, type InferEndpointMiddlewareContext as I, OPTIONS as O, POST as P, type TypedEndpoint as T, isWebResponse as a, type APIRouteParams as b, type APIRouteParamValue as c, type EndpointErrorDefinition as d, type EndpointErrorDefinitions as e, type EndpointErrorContracts as f, type EndpointErrorHandler as g, type EndpointFail as h, invokeAPIRouteEndpoint as i, EndpointFailure as j, isEndpointFailure as k, type EndpointParamValue as l, matchAPIRoute as m, normalizeRouteResponse as n, type EndpointParams as o, type EndpointMiddlewareContext as p, type EndpointMiddlewareResult as q, type EndpointMiddleware as r, type AnyEndpointMiddleware as s, type EndpointInvalidationTarget as t, type EndpointInvalidationContext as u, type EndpointInvalidations as v, type EndpointOptions as w, type EndpointHandler as x, createEndpoint as y, PUT as z };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { F as FarmLocaleResolution } from './resolver-IH4RmPEl.js';
|
|
2
|
+
import { R as ResolvedFarmI18nConfig, F as FarmI18nCatalogs, a as FarmI18nClientSnapshot } from './types-BMxWr97v.js';
|
|
3
|
+
|
|
4
|
+
declare class FarmI18nRuntime {
|
|
5
|
+
readonly config: ResolvedFarmI18nConfig;
|
|
6
|
+
private catalogs;
|
|
7
|
+
private compiled;
|
|
8
|
+
private warnedMissing;
|
|
9
|
+
constructor(config: ResolvedFarmI18nConfig, catalogs?: FarmI18nCatalogs);
|
|
10
|
+
initialize(): Promise<void>;
|
|
11
|
+
reload(): Promise<void>;
|
|
12
|
+
replaceCatalogs(catalogs: FarmI18nCatalogs): void;
|
|
13
|
+
getCatalogs(): FarmI18nCatalogs;
|
|
14
|
+
resolveRequest(request: Request, options?: {
|
|
15
|
+
redirect?: boolean;
|
|
16
|
+
}): FarmLocaleResolution;
|
|
17
|
+
translate(locale: string, key: string, values?: Record<string, unknown>): string;
|
|
18
|
+
translateRich(locale: string, key: string, values?: Record<string, unknown>): unknown;
|
|
19
|
+
getRawMessage(locale: string, key: string): string;
|
|
20
|
+
hasMessage(locale: string, key: string): boolean;
|
|
21
|
+
getClientSnapshot(resolution: FarmLocaleResolution): FarmI18nClientSnapshot;
|
|
22
|
+
private formatMessage;
|
|
23
|
+
private resolveMessage;
|
|
24
|
+
}
|
|
25
|
+
declare function createFarmI18nRuntime(config: ResolvedFarmI18nConfig, catalogs?: FarmI18nCatalogs): FarmI18nRuntime;
|
|
26
|
+
|
|
27
|
+
export { FarmI18nRuntime as F, createFarmI18nRuntime as c };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { b as SerializedServerFnFailure } from './server-fn-error-DDh14a0V.mjs';
|
|
2
|
+
|
|
3
|
+
declare const DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT = 1000000;
|
|
4
|
+
interface FarmServerActionsConfig {
|
|
5
|
+
/** Additional trusted origins or host patterns, such as https://app.example.com. */
|
|
6
|
+
allowedOrigins?: readonly string[];
|
|
7
|
+
/** Maximum encoded request body size in bytes or as a size string such as "1mb". */
|
|
8
|
+
bodySizeLimit?: number | string;
|
|
9
|
+
}
|
|
10
|
+
interface ResolvedFarmServerActionsConfig {
|
|
11
|
+
allowedOrigins: readonly string[];
|
|
12
|
+
bodySizeLimit: number;
|
|
13
|
+
}
|
|
14
|
+
type ServerActionRequestKind = "javascript" | "form";
|
|
15
|
+
interface PreparedServerActionRequest {
|
|
16
|
+
body: string | FormData;
|
|
17
|
+
contentType: string;
|
|
18
|
+
}
|
|
19
|
+
type SanitizedServerActionError = {
|
|
20
|
+
name: "ServerActionError";
|
|
21
|
+
message: "Server function failed";
|
|
22
|
+
} | SerializedServerFnFailure;
|
|
23
|
+
type ServerActionRequestErrorCode = "BODY_TOO_LARGE" | "INVALID_ACTION_ID" | "INVALID_BODY" | "INVALID_CONTENT_LENGTH" | "INVALID_METHOD" | "INVALID_ORIGIN" | "MISSING_ORIGIN" | "UNSUPPORTED_CONTENT_TYPE";
|
|
24
|
+
declare class ServerActionRequestError extends Error {
|
|
25
|
+
readonly code: ServerActionRequestErrorCode;
|
|
26
|
+
readonly status: number;
|
|
27
|
+
constructor(code: ServerActionRequestErrorCode, status: number, message: string);
|
|
28
|
+
}
|
|
29
|
+
type ServerActionExecutionContext = {
|
|
30
|
+
request: Request;
|
|
31
|
+
signal: AbortSignal;
|
|
32
|
+
invalidations: Set<string>;
|
|
33
|
+
cacheTasks: Set<Promise<void>>;
|
|
34
|
+
};
|
|
35
|
+
declare function resolveServerActionsConfig(config: FarmServerActionsConfig | undefined): ResolvedFarmServerActionsConfig;
|
|
36
|
+
declare function validateServerActionRequest(request: Request, config: ResolvedFarmServerActionsConfig): void;
|
|
37
|
+
declare function prepareServerActionRequest(request: Request, config: ResolvedFarmServerActionsConfig, kind: ServerActionRequestKind, actionId?: string | null): Promise<PreparedServerActionRequest>;
|
|
38
|
+
declare function createServerActionRequestErrorResponse(error: unknown): Response | null;
|
|
39
|
+
declare function sanitizeServerActionError(error: unknown): SanitizedServerActionError;
|
|
40
|
+
declare function runWithServerActionRequest<T>(request: Request, callback: () => T | Promise<T>): Promise<T>;
|
|
41
|
+
declare function getServerActionExecutionContext(): ServerActionExecutionContext | undefined;
|
|
42
|
+
declare function getServerActionSignal(): AbortSignal;
|
|
43
|
+
declare function getServerActionInvalidations(): readonly string[];
|
|
44
|
+
|
|
45
|
+
export { DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT, type FarmServerActionsConfig, type PreparedServerActionRequest, type ResolvedFarmServerActionsConfig, type SanitizedServerActionError, ServerActionRequestError, type ServerActionRequestKind, createServerActionRequestErrorResponse, getServerActionExecutionContext, getServerActionInvalidations, getServerActionSignal, prepareServerActionRequest, resolveServerActionsConfig, runWithServerActionRequest, sanitizeServerActionError, validateServerActionRequest };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { b as SerializedServerFnFailure } from './server-fn-error-DDh14a0V.js';
|
|
2
|
+
|
|
3
|
+
declare const DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT = 1000000;
|
|
4
|
+
interface FarmServerActionsConfig {
|
|
5
|
+
/** Additional trusted origins or host patterns, such as https://app.example.com. */
|
|
6
|
+
allowedOrigins?: readonly string[];
|
|
7
|
+
/** Maximum encoded request body size in bytes or as a size string such as "1mb". */
|
|
8
|
+
bodySizeLimit?: number | string;
|
|
9
|
+
}
|
|
10
|
+
interface ResolvedFarmServerActionsConfig {
|
|
11
|
+
allowedOrigins: readonly string[];
|
|
12
|
+
bodySizeLimit: number;
|
|
13
|
+
}
|
|
14
|
+
type ServerActionRequestKind = "javascript" | "form";
|
|
15
|
+
interface PreparedServerActionRequest {
|
|
16
|
+
body: string | FormData;
|
|
17
|
+
contentType: string;
|
|
18
|
+
}
|
|
19
|
+
type SanitizedServerActionError = {
|
|
20
|
+
name: "ServerActionError";
|
|
21
|
+
message: "Server function failed";
|
|
22
|
+
} | SerializedServerFnFailure;
|
|
23
|
+
type ServerActionRequestErrorCode = "BODY_TOO_LARGE" | "INVALID_ACTION_ID" | "INVALID_BODY" | "INVALID_CONTENT_LENGTH" | "INVALID_METHOD" | "INVALID_ORIGIN" | "MISSING_ORIGIN" | "UNSUPPORTED_CONTENT_TYPE";
|
|
24
|
+
declare class ServerActionRequestError extends Error {
|
|
25
|
+
readonly code: ServerActionRequestErrorCode;
|
|
26
|
+
readonly status: number;
|
|
27
|
+
constructor(code: ServerActionRequestErrorCode, status: number, message: string);
|
|
28
|
+
}
|
|
29
|
+
type ServerActionExecutionContext = {
|
|
30
|
+
request: Request;
|
|
31
|
+
signal: AbortSignal;
|
|
32
|
+
invalidations: Set<string>;
|
|
33
|
+
cacheTasks: Set<Promise<void>>;
|
|
34
|
+
};
|
|
35
|
+
declare function resolveServerActionsConfig(config: FarmServerActionsConfig | undefined): ResolvedFarmServerActionsConfig;
|
|
36
|
+
declare function validateServerActionRequest(request: Request, config: ResolvedFarmServerActionsConfig): void;
|
|
37
|
+
declare function prepareServerActionRequest(request: Request, config: ResolvedFarmServerActionsConfig, kind: ServerActionRequestKind, actionId?: string | null): Promise<PreparedServerActionRequest>;
|
|
38
|
+
declare function createServerActionRequestErrorResponse(error: unknown): Response | null;
|
|
39
|
+
declare function sanitizeServerActionError(error: unknown): SanitizedServerActionError;
|
|
40
|
+
declare function runWithServerActionRequest<T>(request: Request, callback: () => T | Promise<T>): Promise<T>;
|
|
41
|
+
declare function getServerActionExecutionContext(): ServerActionExecutionContext | undefined;
|
|
42
|
+
declare function getServerActionSignal(): AbortSignal;
|
|
43
|
+
declare function getServerActionInvalidations(): readonly string[];
|
|
44
|
+
|
|
45
|
+
export { DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT, type FarmServerActionsConfig, type PreparedServerActionRequest, type ResolvedFarmServerActionsConfig, type SanitizedServerActionError, ServerActionRequestError, type ServerActionRequestKind, createServerActionRequestErrorResponse, getServerActionExecutionContext, getServerActionInvalidations, getServerActionSignal, prepareServerActionRequest, resolveServerActionsConfig, runWithServerActionRequest, sanitizeServerActionError, validateServerActionRequest };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ServerFn } from './server-fn.mjs';
|
|
2
|
+
import './cache.mjs';
|
|
3
|
+
import './server-fn-error-DDh14a0V.mjs';
|
|
4
|
+
|
|
5
|
+
type ServerFnActionStatus = "idle" | "pending" | "success" | "error";
|
|
6
|
+
type ServerFnSubmit<TInput, TResult> = [unknown] extends [TInput] ? (input?: TInput | FormData) => Promise<TResult> : (input: TInput | FormData) => Promise<TResult>;
|
|
7
|
+
type ServerFnOptimisticContext<TInput, TResult> = {
|
|
8
|
+
input: TInput | FormData | undefined;
|
|
9
|
+
formData?: FormData;
|
|
10
|
+
current: TResult | null;
|
|
11
|
+
};
|
|
12
|
+
type UseServerFnOptions<TResult, TError extends Error = Error, TInput = unknown> = {
|
|
13
|
+
initialResult?: TResult | null;
|
|
14
|
+
resetOnSubmit?: boolean;
|
|
15
|
+
throwOnFormError?: boolean;
|
|
16
|
+
optimistic?: (context: ServerFnOptimisticContext<TInput, TResult>) => TResult | null | undefined;
|
|
17
|
+
rollbackOnError?: boolean;
|
|
18
|
+
onSuccess?: (result: TResult) => void;
|
|
19
|
+
onError?: (error: TError) => void;
|
|
20
|
+
onSettled?: (result: TResult | null, error: TError | null) => void;
|
|
21
|
+
};
|
|
22
|
+
type UseServerFnReturn<TInput, TResult, TError extends Error = Error> = {
|
|
23
|
+
pending: boolean;
|
|
24
|
+
status: ServerFnActionStatus;
|
|
25
|
+
result: TResult | null;
|
|
26
|
+
error: TError | null;
|
|
27
|
+
submit: ServerFnSubmit<TInput, TResult>;
|
|
28
|
+
formAction: (formData: FormData) => Promise<void>;
|
|
29
|
+
reset: () => void;
|
|
30
|
+
};
|
|
31
|
+
declare function useServerFn<TInput, TResult, TError extends Error = Error>(serverFn: ServerFn<TInput, TResult, TError>, options?: UseServerFnOptions<TResult, TError, TInput>): UseServerFnReturn<TInput, TResult, TError>;
|
|
32
|
+
|
|
33
|
+
export { type ServerFnActionStatus, type ServerFnOptimisticContext, type ServerFnSubmit, type UseServerFnOptions, type UseServerFnReturn, useServerFn };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ServerFn } from './server-fn.js';
|
|
2
|
+
import './cache.js';
|
|
3
|
+
import './server-fn-error-DDh14a0V.js';
|
|
4
|
+
|
|
5
|
+
type ServerFnActionStatus = "idle" | "pending" | "success" | "error";
|
|
6
|
+
type ServerFnSubmit<TInput, TResult> = [unknown] extends [TInput] ? (input?: TInput | FormData) => Promise<TResult> : (input: TInput | FormData) => Promise<TResult>;
|
|
7
|
+
type ServerFnOptimisticContext<TInput, TResult> = {
|
|
8
|
+
input: TInput | FormData | undefined;
|
|
9
|
+
formData?: FormData;
|
|
10
|
+
current: TResult | null;
|
|
11
|
+
};
|
|
12
|
+
type UseServerFnOptions<TResult, TError extends Error = Error, TInput = unknown> = {
|
|
13
|
+
initialResult?: TResult | null;
|
|
14
|
+
resetOnSubmit?: boolean;
|
|
15
|
+
throwOnFormError?: boolean;
|
|
16
|
+
optimistic?: (context: ServerFnOptimisticContext<TInput, TResult>) => TResult | null | undefined;
|
|
17
|
+
rollbackOnError?: boolean;
|
|
18
|
+
onSuccess?: (result: TResult) => void;
|
|
19
|
+
onError?: (error: TError) => void;
|
|
20
|
+
onSettled?: (result: TResult | null, error: TError | null) => void;
|
|
21
|
+
};
|
|
22
|
+
type UseServerFnReturn<TInput, TResult, TError extends Error = Error> = {
|
|
23
|
+
pending: boolean;
|
|
24
|
+
status: ServerFnActionStatus;
|
|
25
|
+
result: TResult | null;
|
|
26
|
+
error: TError | null;
|
|
27
|
+
submit: ServerFnSubmit<TInput, TResult>;
|
|
28
|
+
formAction: (formData: FormData) => Promise<void>;
|
|
29
|
+
reset: () => void;
|
|
30
|
+
};
|
|
31
|
+
declare function useServerFn<TInput, TResult, TError extends Error = Error>(serverFn: ServerFn<TInput, TResult, TError>, options?: UseServerFnOptions<TResult, TError, TInput>): UseServerFnReturn<TInput, TResult, TError>;
|
|
32
|
+
|
|
33
|
+
export { type ServerFnActionStatus, type ServerFnOptimisticContext, type ServerFnSubmit, type UseServerFnOptions, type UseServerFnReturn, useServerFn };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const FARM_SERVER_FN_FAILURE_SYMBOL: unique symbol;
|
|
2
|
+
type SerializedServerFnFailure = {
|
|
3
|
+
name: "ServerFnFailure";
|
|
4
|
+
message: string;
|
|
5
|
+
code: string;
|
|
6
|
+
status: number;
|
|
7
|
+
data: unknown;
|
|
8
|
+
};
|
|
9
|
+
declare class ServerFnFailure<TCode extends string = string, TData = unknown, TStatus extends number = number> extends Error {
|
|
10
|
+
readonly name: "ServerFnFailure";
|
|
11
|
+
readonly code: TCode;
|
|
12
|
+
readonly data: TData;
|
|
13
|
+
readonly status: TStatus;
|
|
14
|
+
constructor(code: TCode, data: TData, options: {
|
|
15
|
+
status: TStatus;
|
|
16
|
+
message: string;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
declare class ServerActionError extends Error {
|
|
20
|
+
readonly name: "ServerActionError";
|
|
21
|
+
constructor(message?: string);
|
|
22
|
+
}
|
|
23
|
+
declare function isServerFnFailure(value: unknown): value is ServerFnFailure;
|
|
24
|
+
declare function createServerFnTransportError(value: unknown): ServerFnFailure | ServerActionError;
|
|
25
|
+
|
|
26
|
+
export { FARM_SERVER_FN_FAILURE_SYMBOL as F, ServerFnFailure as S, ServerActionError as a, type SerializedServerFnFailure as b, createServerFnTransportError as c, isServerFnFailure as i };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const FARM_SERVER_FN_FAILURE_SYMBOL: unique symbol;
|
|
2
|
+
type SerializedServerFnFailure = {
|
|
3
|
+
name: "ServerFnFailure";
|
|
4
|
+
message: string;
|
|
5
|
+
code: string;
|
|
6
|
+
status: number;
|
|
7
|
+
data: unknown;
|
|
8
|
+
};
|
|
9
|
+
declare class ServerFnFailure<TCode extends string = string, TData = unknown, TStatus extends number = number> extends Error {
|
|
10
|
+
readonly name: "ServerFnFailure";
|
|
11
|
+
readonly code: TCode;
|
|
12
|
+
readonly data: TData;
|
|
13
|
+
readonly status: TStatus;
|
|
14
|
+
constructor(code: TCode, data: TData, options: {
|
|
15
|
+
status: TStatus;
|
|
16
|
+
message: string;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
declare class ServerActionError extends Error {
|
|
20
|
+
readonly name: "ServerActionError";
|
|
21
|
+
constructor(message?: string);
|
|
22
|
+
}
|
|
23
|
+
declare function isServerFnFailure(value: unknown): value is ServerFnFailure;
|
|
24
|
+
declare function createServerFnTransportError(value: unknown): ServerFnFailure | ServerActionError;
|
|
25
|
+
|
|
26
|
+
export { FARM_SERVER_FN_FAILURE_SYMBOL as F, ServerFnFailure as S, ServerActionError as a, type SerializedServerFnFailure as b, createServerFnTransportError as c, isServerFnFailure as i };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { FarmCacheInvalidationTarget } from './cache.mjs';
|
|
2
|
+
import { S as ServerFnFailure, a as ServerActionError } from './server-fn-error-DDh14a0V.mjs';
|
|
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
|
+
|
|
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 };
|