@farm.js/core 0.1.0-beta.14 → 0.1.0-beta.17
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.cjs.map +1 -1
- package/dist/api/route-manager.d.mts +66 -0
- package/dist/api/route-manager.d.ts +66 -0
- package/dist/api/route-manager.mjs +2 -2
- package/dist/api/runtime.cjs.map +1 -1
- package/dist/api/runtime.d.mts +3 -0
- package/dist/api/runtime.d.ts +3 -0
- package/dist/api/runtime.mjs +1 -1
- package/dist/api.cjs +18 -10
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.mts +48 -0
- package/dist/api.d.ts +48 -0
- package/dist/api.mjs +3 -3
- package/dist/app-B0tE1I3o.d.ts +306 -0
- package/dist/app-Dv2JJb7X.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-VUL55IAX.mjs → chunk-2FLBZFPG.mjs} +19 -19
- package/dist/chunk-2FLBZFPG.mjs.map +1 -0
- package/dist/{chunk-B232I2GP.mjs → chunk-3HIVDX7J.mjs} +12 -1
- package/dist/chunk-3HIVDX7J.mjs.map +1 -0
- package/dist/{chunk-JDEOUK5V.mjs → chunk-6YXKHAFU.mjs} +3 -3
- package/dist/{chunk-Z5CQMP54.mjs → chunk-ARRYKOI5.mjs} +2 -2
- package/dist/{chunk-KLA67WKG.mjs → chunk-B3FFOIWS.mjs} +2 -2
- package/dist/chunk-E257KFBU.mjs +227 -0
- package/dist/chunk-E257KFBU.mjs.map +1 -0
- package/dist/{chunk-PFE6GMNE.mjs → chunk-HMRFYJK6.mjs} +19 -11
- package/dist/chunk-HMRFYJK6.mjs.map +1 -0
- package/dist/{chunk-OPHK6OJN.mjs → chunk-JAEAE27K.mjs} +2 -2
- package/dist/{chunk-32W4QEJP.mjs → chunk-KFTGPFRD.mjs} +1 -1
- package/dist/chunk-KFTGPFRD.mjs.map +1 -0
- package/dist/{chunk-L2PE36GQ.mjs → chunk-PZXBQKCH.mjs} +15 -6
- package/dist/chunk-PZXBQKCH.mjs.map +1 -0
- package/dist/{chunk-UXUAWNO5.mjs → chunk-RIXKJPGI.mjs} +117 -55
- package/dist/chunk-RIXKJPGI.mjs.map +1 -0
- package/dist/{chunk-PNFQQSRA.mjs → chunk-T2M5QANG.mjs} +143 -41
- package/dist/chunk-T2M5QANG.mjs.map +1 -0
- package/dist/{chunk-WDU6QXNK.mjs → chunk-UCYWGN2P.mjs} +1 -1
- package/dist/chunk-UCYWGN2P.mjs.map +1 -0
- package/dist/{chunk-65A7QIKI.mjs → chunk-UMVLB3PN.mjs} +3 -3
- package/dist/chunk-UMVLB3PN.mjs.map +1 -0
- package/dist/{chunk-ARCGE2VT.mjs → chunk-VFDBC3W7.mjs} +2 -2
- package/dist/{chunk-ARCGE2VT.mjs.map → chunk-VFDBC3W7.mjs.map} +1 -1
- package/dist/{chunk-VY2UYN5R.mjs → chunk-VPCFICID.mjs} +82 -3
- package/dist/chunk-VPCFICID.mjs.map +1 -0
- package/dist/{chunk-H3TE3LOV.mjs → chunk-XMFTIVJH.mjs} +2 -2
- package/dist/{chunk-UB5UOSHB.mjs → chunk-ZVMV3THA.mjs} +71 -2
- package/dist/chunk-ZVMV3THA.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-278AvYHE.d.mts +2021 -0
- package/dist/client-plugins-CTQAkr7R.d.ts +2021 -0
- package/dist/client-plugins.d.mts +24 -0
- package/dist/client-plugins.d.ts +24 -0
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.mts +452 -0
- package/dist/client.d.ts +452 -0
- package/dist/client.mjs +3 -3
- 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.cjs +12 -0
- package/dist/deployment.cjs.map +1 -1
- package/dist/deployment.d.mts +36 -0
- package/dist/deployment.d.ts +36 -0
- package/dist/deployment.mjs +3 -1
- package/dist/{devtools-GAZ7F3KL.mjs → devtools-K2ERKGNI.mjs} +5 -5
- 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 +5 -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 +598 -109
- 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 +45 -29
- 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 +438 -176
- 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 +13 -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 +140 -1
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +41 -0
- package/dist/internal/config-runtime.d.ts +41 -0
- package/dist/internal/config-runtime.mjs +4 -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.d.mts +44 -0
- package/dist/internal/production-runtime.d.ts +44 -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-DmCudMw_.d.mts +22 -0
- package/dist/metadata-xghtOlbR.d.ts +22 -0
- package/dist/middleware.cjs +116 -98
- 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 +5 -2
- package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
- package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
- package/dist/navigation.cjs.map +1 -1
- package/dist/navigation.d.mts +14 -0
- package/dist/navigation.d.ts +14 -0
- package/dist/navigation.mjs +3 -3
- 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 +247 -28
- 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 +10 -10
- package/dist/production-runtime-BLxSv9cU.d.ts +79 -0
- package/dist/production-runtime-DFN2_RXq.d.mts +79 -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-Cq5d6qmE.d.mts +6 -0
- package/dist/request-LoxDW3lp.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-BA9TOSu1.d.mts +231 -0
- package/dist/runtime-Cxpq6xZN.d.mts +27 -0
- package/dist/runtime-DTAQ2HDv.d.ts +231 -0
- package/dist/runtime-bv63eUiO.d.ts +27 -0
- package/dist/server-action-security.cjs +23 -1
- package/dist/server-action-security.cjs.map +1 -1
- package/dist/server-action-security.d.mts +45 -0
- package/dist/server-action-security.d.ts +45 -0
- package/dist/server-action-security.mjs +1 -1
- package/dist/server-fn-client.cjs.map +1 -1
- package/dist/server-fn-client.d.mts +33 -0
- package/dist/server-fn-client.d.ts +33 -0
- package/dist/server-fn-client.mjs +1 -1
- package/dist/server-fn-error-DDh14a0V.d.mts +26 -0
- package/dist/server-fn-error-DDh14a0V.d.ts +26 -0
- package/dist/server-fn.cjs +140 -3
- package/dist/server-fn.cjs.map +1 -1
- package/dist/server-fn.d.mts +121 -0
- package/dist/server-fn.d.ts +121 -0
- package/dist/server-fn.mjs +14 -3
- 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.cjs +99 -1
- package/dist/server-query.cjs.map +1 -1
- package/dist/server-query.d.mts +37 -0
- package/dist/server-query.d.ts +37 -0
- package/dist/server-query.mjs +3 -3
- package/dist/server.cjs +403 -33
- 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 +14 -14
- package/dist/storage.d.mts +52 -0
- package/dist/storage.d.ts +52 -0
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.mts +103 -0
- package/dist/testing.d.ts +103 -0
- package/dist/testing.mjs +3 -3
- 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-B6GaYNJL.d.ts +23 -0
- package/dist/utils-CKSHiip6.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 +255 -30
- 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 +10 -10
- package/dist/workflows.d.mts +110 -0
- package/dist/workflows.d.ts +110 -0
- package/package.json +1 -1
- package/types/middleware.d.ts +36 -11
- package/dist/chunk-32W4QEJP.mjs.map +0 -1
- package/dist/chunk-65A7QIKI.mjs.map +0 -1
- package/dist/chunk-B232I2GP.mjs.map +0 -1
- package/dist/chunk-I4CUBGVF.mjs +0 -93
- package/dist/chunk-I4CUBGVF.mjs.map +0 -1
- package/dist/chunk-L2PE36GQ.mjs.map +0 -1
- package/dist/chunk-PFE6GMNE.mjs.map +0 -1
- package/dist/chunk-PNFQQSRA.mjs.map +0 -1
- package/dist/chunk-UB5UOSHB.mjs.map +0 -1
- package/dist/chunk-UXUAWNO5.mjs.map +0 -1
- package/dist/chunk-VUL55IAX.mjs.map +0 -1
- package/dist/chunk-VY2UYN5R.mjs.map +0 -1
- package/dist/chunk-WDU6QXNK.mjs.map +0 -1
- /package/dist/{chunk-JDEOUK5V.mjs.map → chunk-6YXKHAFU.mjs.map} +0 -0
- /package/dist/{chunk-Z5CQMP54.mjs.map → chunk-ARRYKOI5.mjs.map} +0 -0
- /package/dist/{chunk-KLA67WKG.mjs.map → chunk-B3FFOIWS.mjs.map} +0 -0
- /package/dist/{chunk-OPHK6OJN.mjs.map → chunk-JAEAE27K.mjs.map} +0 -0
- /package/dist/{chunk-H3TE3LOV.mjs.map → chunk-XMFTIVJH.mjs.map} +0 -0
- /package/dist/{devtools-GAZ7F3KL.mjs.map → devtools-K2ERKGNI.mjs.map} +0 -0
|
@@ -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 };
|
|
@@ -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 };
|
package/dist/server-fn.mjs
CHANGED
|
@@ -3,8 +3,14 @@ import {
|
|
|
3
3
|
_parseServerFnSchema,
|
|
4
4
|
createServerFn,
|
|
5
5
|
createServerMiddleware
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import
|
|
6
|
+
} from "./chunk-VPCFICID.mjs";
|
|
7
|
+
import {
|
|
8
|
+
FARM_SERVER_FN_FAILURE_SYMBOL,
|
|
9
|
+
ServerActionError,
|
|
10
|
+
ServerFnFailure,
|
|
11
|
+
createServerFnTransportError,
|
|
12
|
+
isServerFnFailure
|
|
13
|
+
} from "./chunk-ZVMV3THA.mjs";
|
|
8
14
|
import "./chunk-LM2YNO4U.mjs";
|
|
9
15
|
import "./chunk-V3XURYJO.mjs";
|
|
10
16
|
import "./chunk-WZ5QFROO.mjs";
|
|
@@ -12,9 +18,14 @@ import "./chunk-RBRLLZL5.mjs";
|
|
|
12
18
|
import "./chunk-7ZY5AIJO.mjs";
|
|
13
19
|
import "./chunk-CGILA3WO.mjs";
|
|
14
20
|
export {
|
|
21
|
+
FARM_SERVER_FN_FAILURE_SYMBOL,
|
|
15
22
|
FARM_SERVER_FN_SYMBOL,
|
|
23
|
+
ServerActionError,
|
|
24
|
+
ServerFnFailure,
|
|
16
25
|
_parseServerFnSchema,
|
|
17
26
|
createServerFn,
|
|
18
|
-
|
|
27
|
+
createServerFnTransportError,
|
|
28
|
+
createServerMiddleware,
|
|
29
|
+
isServerFnFailure
|
|
19
30
|
};
|
|
20
31
|
//# sourceMappingURL=server-fn.mjs.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { bf as RedirectConfig, x as FarmRequest, y as FarmResponse, aF as FarmPluginContext, $ as FarmPlugin, bg as HeaderConfig, bh as RewriteConfig } from './client-plugins-278AvYHE.mjs';
|
|
2
|
+
export { aG as FarmRequestPluginContext, aH as FarmRequestStore } from './client-plugins-278AvYHE.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.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 { bf as RedirectConfig, x as FarmRequest, y as FarmResponse, aF as FarmPluginContext, $ as FarmPlugin, bg as HeaderConfig, bh as RewriteConfig } from './client-plugins-CTQAkr7R.js';
|
|
2
|
+
export { aG as FarmRequestPluginContext, aH as FarmRequestStore } from './client-plugins-CTQAkr7R.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.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 };
|
package/dist/server-query.cjs
CHANGED
|
@@ -806,6 +806,26 @@ __name(stableSerialize, "stableSerialize");
|
|
|
806
806
|
|
|
807
807
|
// src/server-action-security.ts
|
|
808
808
|
var import_node_async_hooks = require("async_hooks");
|
|
809
|
+
|
|
810
|
+
// src/server-fn-error.ts
|
|
811
|
+
var FARM_SERVER_FN_FAILURE_SYMBOL = /* @__PURE__ */ Symbol.for("farm.server-fn.failure");
|
|
812
|
+
var _ServerFnFailure = class _ServerFnFailure extends Error {
|
|
813
|
+
constructor(code, data, options) {
|
|
814
|
+
super(options.message);
|
|
815
|
+
this.name = "ServerFnFailure";
|
|
816
|
+
this.code = code;
|
|
817
|
+
this.data = data;
|
|
818
|
+
this.status = options.status;
|
|
819
|
+
Object.defineProperty(this, FARM_SERVER_FN_FAILURE_SYMBOL, {
|
|
820
|
+
value: true,
|
|
821
|
+
enumerable: false
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
__name(_ServerFnFailure, "ServerFnFailure");
|
|
826
|
+
var ServerFnFailure = _ServerFnFailure;
|
|
827
|
+
|
|
828
|
+
// src/server-action-security.ts
|
|
809
829
|
var SERVER_ACTION_STORAGE_KEY = /* @__PURE__ */ Symbol.for("farm.serverActionStorage");
|
|
810
830
|
var FALLBACK_ABORT_CONTROLLER_KEY = /* @__PURE__ */ Symbol.for("farm.serverActionFallbackAbortController");
|
|
811
831
|
function getServerActionExecutionContext() {
|
|
@@ -858,6 +878,8 @@ function createServerFn(options) {
|
|
|
858
878
|
throw new TypeError("createServerFn requires a handler function");
|
|
859
879
|
}
|
|
860
880
|
const middleware = resolveServerFnMiddleware(options.middleware);
|
|
881
|
+
const errors = normalizeServerFnErrors(options.errors);
|
|
882
|
+
const error = createServerFnErrorHandler(errors);
|
|
861
883
|
const serverFn = /* @__PURE__ */ __name(async (value) => {
|
|
862
884
|
const formData = isFormData(value) ? value : void 0;
|
|
863
885
|
const rawInput = formData ? formDataToObject(formData) : value;
|
|
@@ -875,7 +897,7 @@ function createServerFn(options) {
|
|
|
875
897
|
let resolvedContext = Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
876
898
|
const result = await runServerFnMiddleware(middleware, handlerContext, async (context) => {
|
|
877
899
|
resolvedContext = context.context;
|
|
878
|
-
return options.handler(context);
|
|
900
|
+
return options.handler({ ...context, error });
|
|
879
901
|
});
|
|
880
902
|
const parsedResult = await _parseServerFnSchema(options.output, result, "output");
|
|
881
903
|
if (options.invalidates) {
|
|
@@ -905,6 +927,10 @@ function createServerFn(options) {
|
|
|
905
927
|
value: options.output,
|
|
906
928
|
enumerable: false
|
|
907
929
|
},
|
|
930
|
+
__farmServerFnError: {
|
|
931
|
+
value: void 0,
|
|
932
|
+
enumerable: false
|
|
933
|
+
},
|
|
908
934
|
__farmServerFnMiddleware: {
|
|
909
935
|
value: middleware,
|
|
910
936
|
enumerable: false
|
|
@@ -943,6 +969,78 @@ async function runServerFnMiddleware(middleware, handlerContext, handler) {
|
|
|
943
969
|
return dispatch(0, Object.freeze(/* @__PURE__ */ Object.create(null)));
|
|
944
970
|
}
|
|
945
971
|
__name(runServerFnMiddleware, "runServerFnMiddleware");
|
|
972
|
+
function normalizeServerFnErrors(definitions) {
|
|
973
|
+
if (definitions === void 0) return Object.freeze({});
|
|
974
|
+
if (!isPlainServerFnObject(definitions)) {
|
|
975
|
+
throw new TypeError("createServerFn errors must be an object");
|
|
976
|
+
}
|
|
977
|
+
const normalized = /* @__PURE__ */ Object.create(null);
|
|
978
|
+
for (const [code, definition] of Object.entries(definitions)) {
|
|
979
|
+
if (!code.trim()) {
|
|
980
|
+
throw new TypeError("Server function error codes cannot be empty");
|
|
981
|
+
}
|
|
982
|
+
if (!definition || typeof definition !== "object") {
|
|
983
|
+
throw new TypeError(`Server function error "${code}" must be an object`);
|
|
984
|
+
}
|
|
985
|
+
if (!Number.isInteger(definition.status) || definition.status < 400 || definition.status > 599) {
|
|
986
|
+
throw new TypeError(
|
|
987
|
+
`Server function error "${code}" status must be an integer between 400 and 599`
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
if (!definition.data || typeof definition.data.parse !== "function" && typeof definition.data.safeParse !== "function") {
|
|
991
|
+
throw new TypeError(
|
|
992
|
+
`Server function error "${code}" data must provide synchronous parse() or safeParse()`
|
|
993
|
+
);
|
|
994
|
+
}
|
|
995
|
+
if (definition.message !== void 0 && typeof definition.message !== "string") {
|
|
996
|
+
throw new TypeError(`Server function error "${code}" message must be a string`);
|
|
997
|
+
}
|
|
998
|
+
normalized[code] = Object.freeze({ ...definition });
|
|
999
|
+
}
|
|
1000
|
+
return Object.freeze(normalized);
|
|
1001
|
+
}
|
|
1002
|
+
__name(normalizeServerFnErrors, "normalizeServerFnErrors");
|
|
1003
|
+
function createServerFnErrorHandler(definitions) {
|
|
1004
|
+
return ((code, data) => {
|
|
1005
|
+
const definition = definitions[code];
|
|
1006
|
+
if (!definition) {
|
|
1007
|
+
throw new TypeError(`Server function error "${code}" is not declared`);
|
|
1008
|
+
}
|
|
1009
|
+
const parsed = parseServerFnFailureData(code, definition.data, data);
|
|
1010
|
+
throw new ServerFnFailure(code, parsed, {
|
|
1011
|
+
status: definition.status,
|
|
1012
|
+
message: definition.message ?? "Server function failed"
|
|
1013
|
+
});
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
__name(createServerFnErrorHandler, "createServerFnErrorHandler");
|
|
1017
|
+
function parseServerFnFailureData(code, schema, value) {
|
|
1018
|
+
if (typeof schema.safeParse === "function") {
|
|
1019
|
+
const result2 = schema.safeParse(value);
|
|
1020
|
+
if (isPromiseLike(result2)) {
|
|
1021
|
+
throw new TypeError(`Server function error "${code}" data schema must parse synchronously`);
|
|
1022
|
+
}
|
|
1023
|
+
return unwrapSafeParseResult(result2);
|
|
1024
|
+
}
|
|
1025
|
+
const result = schema.parse(value);
|
|
1026
|
+
if (isPromiseLike(result)) {
|
|
1027
|
+
throw new TypeError(`Server function error "${code}" data schema must parse synchronously`);
|
|
1028
|
+
}
|
|
1029
|
+
return result;
|
|
1030
|
+
}
|
|
1031
|
+
__name(parseServerFnFailureData, "parseServerFnFailureData");
|
|
1032
|
+
function isPlainServerFnObject(value) {
|
|
1033
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
1034
|
+
const prototype = Object.getPrototypeOf(value);
|
|
1035
|
+
return prototype === Object.prototype || prototype === null;
|
|
1036
|
+
}
|
|
1037
|
+
__name(isPlainServerFnObject, "isPlainServerFnObject");
|
|
1038
|
+
function isPromiseLike(value) {
|
|
1039
|
+
return Boolean(
|
|
1040
|
+
value && (typeof value === "object" || typeof value === "function") && "then" in value && typeof value.then === "function"
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
__name(isPromiseLike, "isPromiseLike");
|
|
946
1044
|
function resolveServerFnMiddleware(middleware) {
|
|
947
1045
|
const resolved = [];
|
|
948
1046
|
const seen = /* @__PURE__ */ new Set();
|