@farm.js/core 0.1.0-beta.16 → 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.d.mts +66 -0
- package/dist/api/route-manager.d.ts +66 -0
- package/dist/api/runtime.d.mts +3 -0
- package/dist/api/runtime.d.ts +3 -0
- package/dist/api.d.mts +48 -0
- package/dist/api.d.ts +48 -0
- 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-AN3PQVKH.mjs → chunk-2FLBZFPG.mjs} +9 -7
- package/dist/chunk-2FLBZFPG.mjs.map +1 -0
- package/dist/chunk-E257KFBU.mjs +227 -0
- package/dist/chunk-E257KFBU.mjs.map +1 -0
- package/dist/{chunk-SLDBGSC3.mjs → chunk-JAEAE27K.mjs} +2 -2
- package/dist/{chunk-T2KL7VEL.mjs → chunk-PZXBQKCH.mjs} +13 -4
- 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-OSWV5IJB.mjs → chunk-T2M5QANG.mjs} +32 -9
- package/dist/chunk-T2M5QANG.mjs.map +1 -0
- package/dist/{chunk-BWJC5ZOD.mjs → chunk-VFDBC3W7.mjs} +2 -2
- package/dist/{chunk-BWJC5ZOD.mjs.map → chunk-VFDBC3W7.mjs.map} +1 -1
- 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.d.mts +452 -0
- package/dist/client.d.ts +452 -0
- package/dist/config.d.mts +31 -0
- package/dist/config.d.ts +31 -0
- package/dist/cron.d.mts +78 -0
- package/dist/cron.d.ts +78 -0
- package/dist/deferred.d.mts +42 -0
- package/dist/deferred.d.ts +42 -0
- package/dist/deployment.d.mts +36 -0
- package/dist/deployment.d.ts +36 -0
- package/dist/{devtools-E4YNCY5J.mjs → devtools-K2ERKGNI.mjs} +3 -3
- 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 +3 -3
- 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 +293 -58
- 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 +22 -18
- 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 +306 -137
- 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 +7 -7
- 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 +2 -2
- 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.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 +132 -0
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +24 -0
- package/dist/plugin.d.ts +24 -0
- package/dist/plugin.mjs +4 -4
- 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.d.mts +45 -0
- package/dist/server-action-security.d.ts +45 -0
- package/dist/server-fn-client.d.mts +33 -0
- package/dist/server-fn-client.d.ts +33 -0
- package/dist/server-fn-error-DDh14a0V.d.mts +26 -0
- package/dist/server-fn-error-DDh14a0V.d.ts +26 -0
- package/dist/server-fn.d.mts +121 -0
- package/dist/server-fn.d.ts +121 -0
- package/dist/server-plugins.d.mts +57 -0
- package/dist/server-plugins.d.ts +57 -0
- package/dist/server-query-client.d.mts +51 -0
- package/dist/server-query-client.d.ts +51 -0
- package/dist/server-query.d.mts +37 -0
- package/dist/server-query.d.ts +37 -0
- package/dist/server.cjs +170 -3
- 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 +6 -6
- package/dist/storage.d.mts +52 -0
- package/dist/storage.d.ts +52 -0
- package/dist/testing.d.mts +103 -0
- package/dist/testing.d.ts +103 -0
- package/dist/transport-BmbGTXA5.d.mts +49 -0
- package/dist/transport-BmbGTXA5.d.ts +49 -0
- package/dist/types-BMxWr97v.d.mts +81 -0
- package/dist/types-BMxWr97v.d.ts +81 -0
- package/dist/types-D1A6-XvH.d.mts +73 -0
- package/dist/types-D1A6-XvH.d.ts +73 -0
- package/dist/types-DTzm4TCl.d.mts +78 -0
- package/dist/types-DTzm4TCl.d.ts +78 -0
- package/dist/utils-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 +140 -2
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +24 -0
- package/dist/vite.d.ts +24 -0
- package/dist/vite.mjs +4 -4
- 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-AN3PQVKH.mjs.map +0 -1
- package/dist/chunk-I4CUBGVF.mjs +0 -93
- package/dist/chunk-I4CUBGVF.mjs.map +0 -1
- package/dist/chunk-OSWV5IJB.mjs.map +0 -1
- package/dist/chunk-T2KL7VEL.mjs.map +0 -1
- package/dist/chunk-UXUAWNO5.mjs.map +0 -1
- /package/dist/{chunk-SLDBGSC3.mjs.map → chunk-JAEAE27K.mjs.map} +0 -0
- /package/dist/{devtools-E4YNCY5J.mjs.map → devtools-K2ERKGNI.mjs.map} +0 -0
|
@@ -0,0 +1,2021 @@
|
|
|
1
|
+
import { n as FarmClientPlugin } from './plugin-BJDf43dc.js';
|
|
2
|
+
import React__default, { ComponentType, ReactNode } from 'react';
|
|
3
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
4
|
+
import { k as FarmStorageUserConfig } from './types-D1A6-XvH.js';
|
|
5
|
+
import { F as FarmIntegrationAPI, f as FarmIntegrationAPIMethod, e as FarmIntegrationAPIBodyFormat, a as FarmIntegrationAPIOperation, g as FarmIntegrationAPIResponseFormat, h as FarmIntegrationRouteOperationCarrier, I as InferIntegrationAPIFromRoutes } from './integration-api-CHT2OKAf.js';
|
|
6
|
+
import { OrmClient, SchemaDefinition, ModelDefinition, FieldBuilder, JsonValue, AnyModelDefinition, SchemaModels } from '@farming-labs/orm';
|
|
7
|
+
import { a as FarmDocsUserConfig, F as FarmDocsResolvedConfig } from './types-DTzm4TCl.js';
|
|
8
|
+
import { FarmMarkdownUserConfig, FarmMarkdownResolvedConfig } from './markdown.js';
|
|
9
|
+
import { FarmObservabilityUserConfig } from './observability.js';
|
|
10
|
+
import * as vite from 'vite';
|
|
11
|
+
import { ViteDevServer, UserConfig, Plugin } from 'vite';
|
|
12
|
+
import { FarmWorkflowsUserConfig, FarmWorkflowsResolvedConfig } from './workflows.js';
|
|
13
|
+
import { FarmCronUserConfig, FarmCronResolvedConfig } from './cron.js';
|
|
14
|
+
import { FarmEnvConfig, ResolvedFarmEnv } from './env.js';
|
|
15
|
+
import { FarmServerActionsConfig, ResolvedFarmServerActionsConfig } from './server-action-security.js';
|
|
16
|
+
import { F as FarmImageConfig, R as ResolvedFarmImageConfig } from './image-config-Duob7wER.js';
|
|
17
|
+
import { k as FarmI18nUserConfig, R as ResolvedFarmI18nConfig } from './types-BMxWr97v.js';
|
|
18
|
+
import { FarmCacheUserConfig } from './cache.js';
|
|
19
|
+
import { F as FarmRouteRuntimeConfig, a as FarmRouteRuntime, b as FarmRouteRegions, c as FarmRouteMaxDuration } from './route-runtime-DoOHzCAD.js';
|
|
20
|
+
import { FarmLayoutFonts } from './font.js';
|
|
21
|
+
|
|
22
|
+
type RuntimeClientFactory<TClient> = () => TClient | Promise<TClient>;
|
|
23
|
+
type FarmIntegrationOrmSchema = SchemaDefinition<Record<string, AnyModelDefinition>>;
|
|
24
|
+
type FarmIntegrationOrmClient<TSchema extends FarmIntegrationOrmSchema> = OrmClient<TSchema>;
|
|
25
|
+
type FarmIntegrationOrmFieldKind<TField extends FarmIntegrationSchemaField> = TField["type"] extends "id" | "uuid" ? "id" : TField["type"] extends "text" ? "string" : TField["type"] extends "number" ? "decimal" : Extract<TField["type"], "string" | "boolean" | "integer" | "datetime" | "json" | "enum">;
|
|
26
|
+
type FarmIntegrationOrmFieldNullable<TField extends FarmIntegrationSchemaField> = TField extends {
|
|
27
|
+
nullable: true;
|
|
28
|
+
} ? true : TField extends {
|
|
29
|
+
required: false;
|
|
30
|
+
} ? true : false;
|
|
31
|
+
type FarmIntegrationOrmEnumValue<TField extends FarmIntegrationSchemaField> = TField extends {
|
|
32
|
+
values: readonly (infer TValue extends string)[];
|
|
33
|
+
} ? TValue : string;
|
|
34
|
+
type FarmIntegrationOrmFieldValue<TField extends FarmIntegrationSchemaField> = TField["type"] extends "id" | "uuid" | "string" | "text" ? string : TField["type"] extends "boolean" ? boolean : TField["type"] extends "integer" ? number : TField["type"] extends "number" ? string : TField["type"] extends "datetime" ? Date : TField["type"] extends "json" ? JsonValue : TField["type"] extends "enum" ? FarmIntegrationOrmEnumValue<TField> : never;
|
|
35
|
+
type InferFarmIntegrationOrmField<TField extends FarmIntegrationSchemaField> = FieldBuilder<FarmIntegrationOrmFieldKind<TField>, FarmIntegrationOrmFieldNullable<TField>, FarmIntegrationOrmFieldValue<TField>>;
|
|
36
|
+
type InferFarmIntegrationOrmFields<TModel extends FarmIntegrationSchemaModel> = {
|
|
37
|
+
[TFieldKey in keyof TModel["fields"] & string]: InferFarmIntegrationOrmField<Extract<TModel["fields"][TFieldKey], FarmIntegrationSchemaField>>;
|
|
38
|
+
};
|
|
39
|
+
type InferFarmIntegrationOrmSchema<TSchema extends FarmIntegrationSchema> = SchemaDefinition<{
|
|
40
|
+
[TModelKey in keyof TSchema["models"] & string]: ModelDefinition<InferFarmIntegrationOrmFields<Extract<TSchema["models"][TModelKey], FarmIntegrationSchemaModel>>, {}>;
|
|
41
|
+
}>;
|
|
42
|
+
type InferFarmIntegrationOrmClient<TSchema extends FarmIntegrationSchema | undefined> = TSchema extends FarmIntegrationSchema ? OrmClient<InferFarmIntegrationOrmSchema<TSchema>> : never;
|
|
43
|
+
interface CreateIntegrationOrmOptions<TClient = unknown, TSchema extends FarmIntegrationSchema = FarmIntegrationSchema> {
|
|
44
|
+
schema: TSchema;
|
|
45
|
+
config?: Pick<FarmConfig, "storage">;
|
|
46
|
+
storage?: FarmStorageUserConfig;
|
|
47
|
+
client?: TClient | RuntimeClientFactory<TClient>;
|
|
48
|
+
}
|
|
49
|
+
declare function createIntegrationOrm<TClient = unknown, TSchema extends FarmIntegrationSchema = FarmIntegrationSchema>(options: CreateIntegrationOrmOptions<TClient, TSchema>): Promise<InferFarmIntegrationOrmClient<TSchema>>;
|
|
50
|
+
declare function resolveIntegrationOrmRuntimeClient<TClient = unknown>(options: Omit<CreateIntegrationOrmOptions<TClient>, "schema">): Promise<TClient | unknown | undefined>;
|
|
51
|
+
declare function farmIntegrationSchemaToOrmSchema(schema: FarmIntegrationSchema): Promise<FarmIntegrationOrmSchema>;
|
|
52
|
+
type IntegrationOrmModelNames<TSchema extends FarmIntegrationOrmSchema> = keyof SchemaModels<TSchema> & string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Farm.js Middleware System
|
|
56
|
+
*
|
|
57
|
+
* Type definitions for the middleware system
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Next function type for middleware chain
|
|
62
|
+
*/
|
|
63
|
+
type MiddlewareResult = void | Response;
|
|
64
|
+
type NextFunction = () => Promise<MiddlewareResult>;
|
|
65
|
+
type MiddlewareStoreKey<TValues extends Record<string, any>> = Extract<keyof TValues, string>;
|
|
66
|
+
/**
|
|
67
|
+
* A typed view over the request-scoped maps used by middleware.
|
|
68
|
+
*/
|
|
69
|
+
interface ReadonlyMiddlewareStore<TValues extends Record<string, any> = Record<string, any>> {
|
|
70
|
+
readonly size: number;
|
|
71
|
+
get<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): TValues[TKey] | undefined;
|
|
72
|
+
has<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
|
|
73
|
+
entries(): IterableIterator<[MiddlewareStoreKey<TValues>, TValues[MiddlewareStoreKey<TValues>]]>;
|
|
74
|
+
keys(): IterableIterator<MiddlewareStoreKey<TValues>>;
|
|
75
|
+
values(): IterableIterator<TValues[MiddlewareStoreKey<TValues>]>;
|
|
76
|
+
forEach(callback: (value: TValues[MiddlewareStoreKey<TValues>], key: MiddlewareStoreKey<TValues>, store: ReadonlyMiddlewareStore<TValues>) => void, thisArg?: any): void;
|
|
77
|
+
[Symbol.iterator](): IterableIterator<[
|
|
78
|
+
MiddlewareStoreKey<TValues>,
|
|
79
|
+
TValues[MiddlewareStoreKey<TValues>]
|
|
80
|
+
]>;
|
|
81
|
+
}
|
|
82
|
+
interface MiddlewareStore<TValues extends Record<string, any> = Record<string, any>> extends ReadonlyMiddlewareStore<TValues> {
|
|
83
|
+
clear(): void;
|
|
84
|
+
delete<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
|
|
85
|
+
set<TKey extends MiddlewareStoreKey<TValues>>(key: TKey, value: TValues[TKey]): this;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Middleware function signature
|
|
89
|
+
*/
|
|
90
|
+
type MiddlewareFunction = (ctx: MiddlewareContext, next: NextFunction) => MiddlewareResult | Promise<MiddlewareResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Context passed to a named, request-first middleware export.
|
|
93
|
+
* `locals` and the get/set helpers stay on the server. `data` can be exposed
|
|
94
|
+
* through page props and should contain only serializable, client-safe values.
|
|
95
|
+
*/
|
|
96
|
+
interface RequestMiddlewareContext<TLocals extends Record<string, any> = Record<string, any>, TData extends Record<string, any> = Record<string, any>> {
|
|
97
|
+
readonly url: URL;
|
|
98
|
+
readonly pathname: string;
|
|
99
|
+
readonly searchParams: URLSearchParams;
|
|
100
|
+
readonly method: string;
|
|
101
|
+
readonly params: Record<string, string>;
|
|
102
|
+
readonly route: string;
|
|
103
|
+
readonly locals: MiddlewareStore<TLocals>;
|
|
104
|
+
readonly data: MiddlewareStore<TData>;
|
|
105
|
+
readonly headers: Map<string, string>;
|
|
106
|
+
readonly cookies: CookieJar;
|
|
107
|
+
get<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): TLocals[TKey] | undefined;
|
|
108
|
+
has<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
|
|
109
|
+
set<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey, value: TLocals[TKey]): void;
|
|
110
|
+
delete<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
|
|
111
|
+
redirect(url: string, status?: number): void;
|
|
112
|
+
rewrite(url: string): void;
|
|
113
|
+
json(data: any, status?: number): void;
|
|
114
|
+
text(content: string, status?: number): void;
|
|
115
|
+
html(content: string, status?: number): void;
|
|
116
|
+
}
|
|
117
|
+
type RequestMiddleware<TLocals extends Record<string, any> = Record<string, any>, TData extends Record<string, any> = Record<string, any>> = (request: Request, context: RequestMiddlewareContext<TLocals, TData>) => MiddlewareResult | Promise<MiddlewareResult>;
|
|
118
|
+
/**
|
|
119
|
+
* Cookie options
|
|
120
|
+
*/
|
|
121
|
+
interface CookieOptions {
|
|
122
|
+
maxAge?: number;
|
|
123
|
+
expires?: Date;
|
|
124
|
+
path?: string;
|
|
125
|
+
domain?: string;
|
|
126
|
+
secure?: boolean;
|
|
127
|
+
httpOnly?: boolean;
|
|
128
|
+
sameSite?: "strict" | "lax" | "none";
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Cookie management interface
|
|
132
|
+
*/
|
|
133
|
+
interface CookieJar {
|
|
134
|
+
get(name: string): string | undefined;
|
|
135
|
+
set(name: string, value: string, options?: CookieOptions): void;
|
|
136
|
+
delete(name: string): void;
|
|
137
|
+
getAll(): Record<string, string>;
|
|
138
|
+
}
|
|
139
|
+
interface RateLimitIncrementResult {
|
|
140
|
+
count: number;
|
|
141
|
+
/** Unix epoch timestamp in milliseconds when the fixed window resets. */
|
|
142
|
+
resetAt: number;
|
|
143
|
+
}
|
|
144
|
+
interface RateLimitStorage {
|
|
145
|
+
/** Atomically increment a key and create or retain its fixed expiry window. */
|
|
146
|
+
increment(key: string, windowMs: number): Promise<RateLimitIncrementResult> | RateLimitIncrementResult;
|
|
147
|
+
/** Optional inspection support used by getRateLimitStatus(). */
|
|
148
|
+
get?(key: string): Promise<RateLimitIncrementResult | null> | RateLimitIncrementResult | null;
|
|
149
|
+
}
|
|
150
|
+
interface MemoryRateLimitStorageOptions {
|
|
151
|
+
/** Maximum number of active keys retained by this process. */
|
|
152
|
+
maxEntries?: number;
|
|
153
|
+
}
|
|
154
|
+
interface RateLimitConfig {
|
|
155
|
+
requests: number;
|
|
156
|
+
window: string;
|
|
157
|
+
keyGenerator?: (ctx: MiddlewareContext) => string;
|
|
158
|
+
onLimit?: (ctx: MiddlewareContext) => void | Response | Promise<void | Response>;
|
|
159
|
+
storage?: RateLimitStorage;
|
|
160
|
+
}
|
|
161
|
+
interface RateLimitStatus {
|
|
162
|
+
requests: number;
|
|
163
|
+
limit: number;
|
|
164
|
+
remaining: number;
|
|
165
|
+
resetIn: number | null;
|
|
166
|
+
resetAt: Date | null;
|
|
167
|
+
isLimited: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Middleware configuration
|
|
171
|
+
*/
|
|
172
|
+
type MiddlewareMatcher = string | RegExp | ((ctx: MiddlewareContext) => boolean);
|
|
173
|
+
interface MiddlewareConfig$1 {
|
|
174
|
+
matcher?: MiddlewareMatcher | MiddlewareMatcher[];
|
|
175
|
+
exclude?: (string | RegExp)[];
|
|
176
|
+
runtime?: "nodejs" | "edge";
|
|
177
|
+
}
|
|
178
|
+
interface MiddlewareConfigEntry extends MiddlewareConfig$1 {
|
|
179
|
+
handler?: MiddlewareFunction;
|
|
180
|
+
handlers?: MiddlewareFunction[];
|
|
181
|
+
}
|
|
182
|
+
type FarmMiddlewareConfig = MiddlewareConfig$1 | MiddlewareConfigEntry | MiddlewareConfigEntry[];
|
|
183
|
+
/**
|
|
184
|
+
* Middleware context - the main object passed to middleware functions
|
|
185
|
+
*/
|
|
186
|
+
interface MiddlewareContext {
|
|
187
|
+
request: IncomingMessage;
|
|
188
|
+
response: ServerResponse;
|
|
189
|
+
url: URL;
|
|
190
|
+
pathname: string;
|
|
191
|
+
searchParams: URLSearchParams;
|
|
192
|
+
method: string;
|
|
193
|
+
params: Record<string, string>;
|
|
194
|
+
route: string;
|
|
195
|
+
parent?: {
|
|
196
|
+
data: Map<string, any>;
|
|
197
|
+
locals?: Map<string, any>;
|
|
198
|
+
headers: Record<string, string>;
|
|
199
|
+
};
|
|
200
|
+
vite: {
|
|
201
|
+
isDev: boolean;
|
|
202
|
+
hmr: boolean;
|
|
203
|
+
server?: ViteDevServer;
|
|
204
|
+
};
|
|
205
|
+
data: Map<string, any>;
|
|
206
|
+
locals: Map<string, any>;
|
|
207
|
+
headers: Map<string, string>;
|
|
208
|
+
cookies: CookieJar;
|
|
209
|
+
_handled: boolean;
|
|
210
|
+
_redirectUrl?: string;
|
|
211
|
+
_rewriteUrl?: string;
|
|
212
|
+
redirect(url: string, status?: number): void;
|
|
213
|
+
rewrite(url: string): void;
|
|
214
|
+
json(data: any, status?: number): void;
|
|
215
|
+
text(content: string, status?: number): void;
|
|
216
|
+
html(content: string, status?: number): void;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Middleware chain interface
|
|
220
|
+
*/
|
|
221
|
+
interface MiddlewareChain {
|
|
222
|
+
use(fn: MiddlewareFunction): MiddlewareChain;
|
|
223
|
+
/**
|
|
224
|
+
* Conditionally run middleware based on a condition.
|
|
225
|
+
* Supports boolean values or functions that evaluate to boolean.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* .when(true, (ctx, next) => { ... }) // Always run
|
|
229
|
+
* .when((ctx) => ctx.data.get('flag'), (ctx, next) => { ... }) // Conditional
|
|
230
|
+
*/
|
|
231
|
+
when(condition: boolean | ((ctx: MiddlewareContext) => boolean), fn: MiddlewareFunction | ((chain: MiddlewareChain) => void)): MiddlewareChain;
|
|
232
|
+
rateLimit(config: RateLimitConfig): MiddlewareChain;
|
|
233
|
+
redirect(source: string, destination: string, permanent?: boolean): MiddlewareChain;
|
|
234
|
+
/**
|
|
235
|
+
* Rewrite the current route to a new destination.
|
|
236
|
+
* In route-specific middleware, this rewrites the middleware's route.
|
|
237
|
+
*
|
|
238
|
+
* @param destination - The destination path to rewrite to
|
|
239
|
+
* @param condition - Optional boolean or function that evaluates to boolean. If false, rewrite is skipped.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* // In /contact/middleware.ts
|
|
243
|
+
* .rewrite('/about') // Always rewrites /contact to /about
|
|
244
|
+
* .rewrite('/about', true) // Always rewrites
|
|
245
|
+
* .rewrite('/about', false) // Never rewrites
|
|
246
|
+
* .rewrite('/about', (ctx) => ctx.data.get('shouldRewrite')) // Conditional rewrite
|
|
247
|
+
*/
|
|
248
|
+
rewrite(destination: string, condition?: boolean | ((ctx: MiddlewareContext) => boolean)): MiddlewareChain;
|
|
249
|
+
build(): {
|
|
250
|
+
handlers: MiddlewareFunction[];
|
|
251
|
+
config?: MiddlewareConfig$1;
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Middleware module export
|
|
256
|
+
*/
|
|
257
|
+
interface MiddlewareModule {
|
|
258
|
+
default?: MiddlewareChain | MiddlewareFunction;
|
|
259
|
+
middleware?: RequestMiddleware;
|
|
260
|
+
config?: MiddlewareConfig$1;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
type FarmMdxComponent = React__default.ComponentType<any> | keyof React__default.JSX.IntrinsicElements;
|
|
264
|
+
type FarmMdxComponents = Record<string, FarmMdxComponent>;
|
|
265
|
+
interface FarmMdxUserConfig {
|
|
266
|
+
/**
|
|
267
|
+
* Component map or module path that exports `components` or a default component map.
|
|
268
|
+
* Relative paths resolve from the project root.
|
|
269
|
+
*/
|
|
270
|
+
components?: string | FarmMdxComponents;
|
|
271
|
+
/**
|
|
272
|
+
* Serve source-authored markdown pages at `/route.md`.
|
|
273
|
+
* Enabled by default for `page.md` and `page.mdx`.
|
|
274
|
+
*/
|
|
275
|
+
markdownRoutes?: boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Class name used for the wrapper around rendered markdown content.
|
|
278
|
+
*/
|
|
279
|
+
className?: string;
|
|
280
|
+
}
|
|
281
|
+
interface FarmMdxResolvedConfig {
|
|
282
|
+
components?: string | FarmMdxComponents;
|
|
283
|
+
markdownRoutes: boolean;
|
|
284
|
+
className: string;
|
|
285
|
+
}
|
|
286
|
+
interface FarmMarkdownPageSource {
|
|
287
|
+
source: string;
|
|
288
|
+
filePath: string;
|
|
289
|
+
}
|
|
290
|
+
interface FarmMarkdownPageModuleInput extends FarmMarkdownPageSource {
|
|
291
|
+
components?: FarmMdxComponents;
|
|
292
|
+
config?: FarmMdxResolvedConfig;
|
|
293
|
+
}
|
|
294
|
+
declare function resolveMdxConfig(config: FarmMdxUserConfig | undefined): FarmMdxResolvedConfig;
|
|
295
|
+
declare function isFarmMarkdownPageFile(filePath: string): boolean;
|
|
296
|
+
declare function normalizeFarmMarkdownRoutePath(pathname: string): string;
|
|
297
|
+
declare function parseMarkdownFrontmatter(source: string): {
|
|
298
|
+
frontmatter: Record<string, string>;
|
|
299
|
+
body: string;
|
|
300
|
+
};
|
|
301
|
+
declare function titleFromMarkdown(body: string, fallback?: string): string | undefined;
|
|
302
|
+
declare function createMarkdownMetadata(source: string, filePath: string): (Metadata & Record<string, any>) | undefined;
|
|
303
|
+
declare function createFarmMarkdownRouteModule(input: FarmMarkdownPageModuleInput): RouteModule & {
|
|
304
|
+
source: string;
|
|
305
|
+
};
|
|
306
|
+
declare function createFarmMarkdownRouteModuleFromFile(filePath: string, options?: {
|
|
307
|
+
components?: FarmMdxComponents;
|
|
308
|
+
config?: FarmMdxResolvedConfig;
|
|
309
|
+
}): Promise<RouteModule<never> & {
|
|
310
|
+
source: string;
|
|
311
|
+
}>;
|
|
312
|
+
declare function loadFarmMdxComponents(config: FarmMdxResolvedConfig | undefined, options: {
|
|
313
|
+
root: string;
|
|
314
|
+
loadModule?: (modulePath: string) => Promise<unknown>;
|
|
315
|
+
}): Promise<FarmMdxComponents>;
|
|
316
|
+
declare function createFarmMarkdownSourceResponse(options: {
|
|
317
|
+
request: Request;
|
|
318
|
+
config?: FarmMdxResolvedConfig;
|
|
319
|
+
resolveSource: (pathname: string) => Promise<FarmMarkdownPageSource | null> | FarmMarkdownPageSource | null;
|
|
320
|
+
}): Promise<Response | null>;
|
|
321
|
+
|
|
322
|
+
type FarmRouteRuleRenderMode = "static" | "dynamic";
|
|
323
|
+
type FarmRouteRuleRedirect = string | {
|
|
324
|
+
to: string;
|
|
325
|
+
statusCode?: number;
|
|
326
|
+
permanent?: boolean;
|
|
327
|
+
};
|
|
328
|
+
type FarmRouteRuleCors = boolean | {
|
|
329
|
+
origin?: string;
|
|
330
|
+
methods?: string | readonly string[];
|
|
331
|
+
headers?: string | readonly string[];
|
|
332
|
+
};
|
|
333
|
+
interface FarmRouteRule extends FarmRouteRuntimeConfig {
|
|
334
|
+
prerender?: boolean;
|
|
335
|
+
render?: FarmRouteRuleRenderMode;
|
|
336
|
+
ssr?: boolean;
|
|
337
|
+
swr?: boolean | number;
|
|
338
|
+
isr?: boolean | number;
|
|
339
|
+
cors?: FarmRouteRuleCors;
|
|
340
|
+
headers?: Record<string, string>;
|
|
341
|
+
redirect?: FarmRouteRuleRedirect;
|
|
342
|
+
}
|
|
343
|
+
type FarmRouteRules = Record<string, FarmRouteRule>;
|
|
344
|
+
declare function normalizeRouteRules(routeRules: FarmRouteRules | undefined): FarmRouteRules;
|
|
345
|
+
declare function routeRulesToRedirects(routeRules: FarmRouteRules): RedirectConfig[];
|
|
346
|
+
declare function routeRulesToHeaders(routeRules: FarmRouteRules): HeaderConfig[];
|
|
347
|
+
declare function routeRulesToNitroRouteRules(routeRules: FarmRouteRules): Record<string, any>;
|
|
348
|
+
|
|
349
|
+
type FarmLayerEntry = string;
|
|
350
|
+
interface ResolvedFarmLayer {
|
|
351
|
+
/** The value used in `extends`. */
|
|
352
|
+
source: string;
|
|
353
|
+
/** Stable name used by the `#layers/<name>` alias. */
|
|
354
|
+
name: string;
|
|
355
|
+
/** Absolute layer package or directory root. */
|
|
356
|
+
root: string;
|
|
357
|
+
/** Source directory relative to the layer root. */
|
|
358
|
+
srcDir: string;
|
|
359
|
+
/** Resolved layer config file when one exists. */
|
|
360
|
+
configFile?: string;
|
|
361
|
+
}
|
|
362
|
+
interface FarmSourceRoot {
|
|
363
|
+
name: string;
|
|
364
|
+
root: string;
|
|
365
|
+
srcDir: string;
|
|
366
|
+
layer: boolean;
|
|
367
|
+
}
|
|
368
|
+
interface ResolveFarmLayersOptions {
|
|
369
|
+
root: string;
|
|
370
|
+
mode: "development" | "production";
|
|
371
|
+
}
|
|
372
|
+
interface FarmLayerResolution<TConfig extends Record<string, any>> {
|
|
373
|
+
config: TConfig & {
|
|
374
|
+
extends?: readonly FarmLayerEntry[];
|
|
375
|
+
layers: ResolvedFarmLayer[];
|
|
376
|
+
};
|
|
377
|
+
layers: ResolvedFarmLayer[];
|
|
378
|
+
}
|
|
379
|
+
declare function resolveFarmLayers<TConfig extends Record<string, any>>(projectConfig: TConfig, options: ResolveFarmLayersOptions): Promise<FarmLayerResolution<TConfig>>;
|
|
380
|
+
declare function getFarmSourceRoots(config: {
|
|
381
|
+
root?: string;
|
|
382
|
+
srcDir?: string;
|
|
383
|
+
layers?: readonly ResolvedFarmLayer[];
|
|
384
|
+
}): FarmSourceRoot[];
|
|
385
|
+
declare function getFarmAppDirectories(config: {
|
|
386
|
+
root?: string;
|
|
387
|
+
srcDir?: string;
|
|
388
|
+
layers?: readonly ResolvedFarmLayer[];
|
|
389
|
+
}): string[];
|
|
390
|
+
declare function getFarmLayerAliases(layers: readonly ResolvedFarmLayer[] | undefined): Record<string, string>;
|
|
391
|
+
declare function loadFarmConfigFile<TConfig = Record<string, any>>(configPath: string, options: {
|
|
392
|
+
root: string;
|
|
393
|
+
cacheRoot?: string;
|
|
394
|
+
}): Promise<TConfig>;
|
|
395
|
+
|
|
396
|
+
declare const DEFAULT_FARM_DEVTOOLS_SHORTCUT = "mod+shift+.";
|
|
397
|
+
declare const FARM_DEVTOOLS_PATH = "/__farm/devtools";
|
|
398
|
+
declare const FARM_DEVTOOLS_LAUNCH_PARAM = "__farm_devtools";
|
|
399
|
+
interface FarmDevtoolsConfig {
|
|
400
|
+
/** Enable the development-only DevTools UI and runtime endpoints. */
|
|
401
|
+
enabled?: boolean;
|
|
402
|
+
/** Keyboard shortcut used to toggle DevTools, or false to disable the shortcut. */
|
|
403
|
+
shortcut?: string | false;
|
|
404
|
+
}
|
|
405
|
+
type FarmDevtoolsUserConfig = boolean | FarmDevtoolsConfig;
|
|
406
|
+
interface ResolvedFarmDevtoolsConfig {
|
|
407
|
+
enabled: boolean;
|
|
408
|
+
shortcut: string | false;
|
|
409
|
+
}
|
|
410
|
+
declare function resolveFarmDevtoolsConfig(config: FarmDevtoolsUserConfig | ResolvedFarmDevtoolsConfig | undefined, mode?: "development" | "production"): ResolvedFarmDevtoolsConfig;
|
|
411
|
+
|
|
412
|
+
interface FarmAuthEmailAndPasswordConfig {
|
|
413
|
+
/** Require a verified email before creating a session. @default false */
|
|
414
|
+
requireEmailVerification?: boolean;
|
|
415
|
+
/** Smallest accepted password length. @default 8 */
|
|
416
|
+
minPasswordLength?: number;
|
|
417
|
+
/** Largest accepted password length. @default 128 */
|
|
418
|
+
maxPasswordLength?: number;
|
|
419
|
+
}
|
|
420
|
+
interface FarmAuthSessionConfig {
|
|
421
|
+
/** Session lifetime in seconds. @default 604800 */
|
|
422
|
+
expiresIn?: number;
|
|
423
|
+
/** Session refresh interval in seconds. @default 86400 */
|
|
424
|
+
updateAge?: number;
|
|
425
|
+
}
|
|
426
|
+
interface FarmAuthDatabaseConfig {
|
|
427
|
+
/**
|
|
428
|
+
* Postgres connection string. Defaults to DATABASE_URL.
|
|
429
|
+
* Local development falls back to SQLite when no URL is present.
|
|
430
|
+
*/
|
|
431
|
+
url?: string;
|
|
432
|
+
/** Local SQLite path. @default ".farm/auth.sqlite" */
|
|
433
|
+
path?: string;
|
|
434
|
+
/** Automatically update the auth schema in development. @default true */
|
|
435
|
+
migrateInDevelopment?: boolean;
|
|
436
|
+
}
|
|
437
|
+
interface FarmAuthConfig {
|
|
438
|
+
/** Set false to disable auth without removing its configuration. @default true */
|
|
439
|
+
enabled?: boolean;
|
|
440
|
+
/** Display name used by authentication emails and metadata. */
|
|
441
|
+
appName?: string;
|
|
442
|
+
/** Route prefix for the auth endpoints. @default "/api/auth" */
|
|
443
|
+
basePath?: string;
|
|
444
|
+
/**
|
|
445
|
+
* Email/password authentication. It is enabled by default; set false to
|
|
446
|
+
* disable it when adding another sign-in method.
|
|
447
|
+
*/
|
|
448
|
+
emailAndPassword?: boolean | FarmAuthEmailAndPasswordConfig;
|
|
449
|
+
session?: FarmAuthSessionConfig;
|
|
450
|
+
database?: FarmAuthDatabaseConfig;
|
|
451
|
+
}
|
|
452
|
+
type FarmAuthUserConfig = boolean | FarmAuthConfig;
|
|
453
|
+
interface ResolvedFarmAuthConfig {
|
|
454
|
+
enabled: boolean;
|
|
455
|
+
appName?: string;
|
|
456
|
+
basePath: string;
|
|
457
|
+
emailAndPassword: {
|
|
458
|
+
enabled: boolean;
|
|
459
|
+
requireEmailVerification: boolean;
|
|
460
|
+
minPasswordLength: number;
|
|
461
|
+
maxPasswordLength: number;
|
|
462
|
+
};
|
|
463
|
+
session: {
|
|
464
|
+
expiresIn: number;
|
|
465
|
+
updateAge: number;
|
|
466
|
+
};
|
|
467
|
+
database: {
|
|
468
|
+
url?: string;
|
|
469
|
+
path: string;
|
|
470
|
+
migrateInDevelopment: boolean;
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
type FarmPreloadMode = "warn" | "enforce";
|
|
475
|
+
interface FarmPreloadUserConfig {
|
|
476
|
+
/** Report excess hints or remove the lower-priority hints. @default "enforce" */
|
|
477
|
+
mode?: FarmPreloadMode;
|
|
478
|
+
/** Maximum image preload hints per document. @default 1 */
|
|
479
|
+
maxImages?: number;
|
|
480
|
+
/** Maximum font preload hints per document. @default 2 */
|
|
481
|
+
maxFonts?: number;
|
|
482
|
+
}
|
|
483
|
+
interface ResolvedFarmPreloadConfig {
|
|
484
|
+
mode: FarmPreloadMode;
|
|
485
|
+
maxImages: number;
|
|
486
|
+
maxFonts: number;
|
|
487
|
+
}
|
|
488
|
+
interface FarmPerformanceConfig {
|
|
489
|
+
preload?: FarmPreloadUserConfig;
|
|
490
|
+
}
|
|
491
|
+
interface ResolvedFarmPerformanceConfig {
|
|
492
|
+
preload: ResolvedFarmPreloadConfig;
|
|
493
|
+
}
|
|
494
|
+
type FarmPreloadKind = "image" | "font";
|
|
495
|
+
interface FarmPreloadBudgetWarning {
|
|
496
|
+
kind: FarmPreloadKind;
|
|
497
|
+
count: number;
|
|
498
|
+
budget: number;
|
|
499
|
+
removed: number;
|
|
500
|
+
}
|
|
501
|
+
interface FarmManagedPreloads {
|
|
502
|
+
value: string;
|
|
503
|
+
warnings: FarmPreloadBudgetWarning[];
|
|
504
|
+
}
|
|
505
|
+
interface FarmManagedDocumentPreloads {
|
|
506
|
+
html: string;
|
|
507
|
+
linkHeader: string;
|
|
508
|
+
warnings: FarmPreloadBudgetWarning[];
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Apply image and font budgets to HTML preload elements. High-priority image
|
|
512
|
+
* hints are retained before ordinary hints, making an explicitly preloaded LCP
|
|
513
|
+
* image the winner when a document contains too many React-generated hints.
|
|
514
|
+
*/
|
|
515
|
+
declare function manageFarmHtmlPreloads(html: string, config: ResolvedFarmPreloadConfig): FarmManagedPreloads;
|
|
516
|
+
/** Apply the same budgets to HTTP Link preload hints, including Farm fonts. */
|
|
517
|
+
declare function manageFarmLinkHeaderPreloads(value: string, config: ResolvedFarmPreloadConfig): FarmManagedPreloads;
|
|
518
|
+
/** Apply a single document budget across HTML and HTTP Link header hints. */
|
|
519
|
+
declare function manageFarmDocumentPreloads(html: string, linkHeader: string, config: ResolvedFarmPreloadConfig): FarmManagedDocumentPreloads;
|
|
520
|
+
/** Rate-limit identical route-and-budget warnings within a server process. */
|
|
521
|
+
declare function reportFarmPreloadWarnings(warnings: FarmPreloadBudgetWarning[], context?: string): void;
|
|
522
|
+
|
|
523
|
+
type FarmCspDirectiveValue = string | readonly string[] | boolean | null | undefined;
|
|
524
|
+
type FarmCspDirectives = Readonly<Record<string, FarmCspDirectiveValue>>;
|
|
525
|
+
interface FarmCspOptions {
|
|
526
|
+
/** A pre-serialized CSP value. Cannot be combined with directives. */
|
|
527
|
+
policy?: string;
|
|
528
|
+
/** CSP directives using camelCase or kebab-case names. */
|
|
529
|
+
directives?: FarmCspDirectives;
|
|
530
|
+
/** Emit Content-Security-Policy-Report-Only instead of enforcing the policy. */
|
|
531
|
+
reportOnly?: boolean;
|
|
532
|
+
}
|
|
533
|
+
type FarmCspConfig = string | FarmCspOptions;
|
|
534
|
+
interface FarmSecurityConfig {
|
|
535
|
+
/** App-wide Content Security Policy applied to pages, APIs, and static output. */
|
|
536
|
+
csp?: FarmCspConfig | false;
|
|
537
|
+
/** @deprecated Use csp. */
|
|
538
|
+
contentSecurityPolicy?: never;
|
|
539
|
+
}
|
|
540
|
+
interface ResolvedFarmCspConfig {
|
|
541
|
+
value: string;
|
|
542
|
+
reportOnly: boolean;
|
|
543
|
+
}
|
|
544
|
+
interface ResolvedFarmSecurityConfig {
|
|
545
|
+
csp: ResolvedFarmCspConfig | false;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
declare const FARM_RESOLVED_CUSTOM_CONTEXT: unique symbol;
|
|
549
|
+
|
|
550
|
+
interface RedirectConfig {
|
|
551
|
+
source: string;
|
|
552
|
+
destination: string;
|
|
553
|
+
permanent?: boolean;
|
|
554
|
+
statusCode?: number;
|
|
555
|
+
}
|
|
556
|
+
interface HeaderConfig {
|
|
557
|
+
source: string;
|
|
558
|
+
headers: Array<{
|
|
559
|
+
key: string;
|
|
560
|
+
value: string;
|
|
561
|
+
}>;
|
|
562
|
+
}
|
|
563
|
+
interface RewriteConfig {
|
|
564
|
+
source: string;
|
|
565
|
+
destination: string;
|
|
566
|
+
}
|
|
567
|
+
/** @deprecated Use FarmImageConfig. */
|
|
568
|
+
type ImageConfig = FarmImageConfig;
|
|
569
|
+
/** @deprecated Use FarmI18nUserConfig. */
|
|
570
|
+
type I18nConfig = FarmI18nUserConfig;
|
|
571
|
+
interface OpenAPIConfig {
|
|
572
|
+
enabled?: boolean;
|
|
573
|
+
route?: string;
|
|
574
|
+
title?: string;
|
|
575
|
+
description?: string;
|
|
576
|
+
version?: string;
|
|
577
|
+
servers?: Array<{
|
|
578
|
+
url: string;
|
|
579
|
+
description?: string;
|
|
580
|
+
}>;
|
|
581
|
+
contact?: {
|
|
582
|
+
name?: string;
|
|
583
|
+
email?: string;
|
|
584
|
+
url?: string;
|
|
585
|
+
};
|
|
586
|
+
license?: {
|
|
587
|
+
name: string;
|
|
588
|
+
url?: string;
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
type MiddlewareConfig = FarmMiddlewareConfig;
|
|
592
|
+
interface NotFoundConfig {
|
|
593
|
+
/** Path to a custom 404 page component (e.g., "./src/app/not-found.tsx") */
|
|
594
|
+
component?: string;
|
|
595
|
+
}
|
|
596
|
+
type FarmDeployTarget = "vercel" | "cloudflare" | "netlify" | "node" | string;
|
|
597
|
+
interface FarmDeployConfig {
|
|
598
|
+
/**
|
|
599
|
+
* Deployment platform. When present, Farm picks the matching Nitro preset and
|
|
600
|
+
* output directory unless explicitly overridden.
|
|
601
|
+
*/
|
|
602
|
+
target?: FarmDeployTarget;
|
|
603
|
+
/** Nitro preset override. Usually inferred from target. */
|
|
604
|
+
preset?: FarmConfig["preset"];
|
|
605
|
+
/** Deployable output directory, relative to project root unless absolute. */
|
|
606
|
+
outputDir?: string;
|
|
607
|
+
/** Alias for outputDir for terser config. */
|
|
608
|
+
output?: string;
|
|
609
|
+
/** Cloudflare Pages project name used by `farm deploy --cloudflare`. */
|
|
610
|
+
projectName?: string;
|
|
611
|
+
vercel?: {
|
|
612
|
+
outputDirectory?: string;
|
|
613
|
+
buildCommand?: string;
|
|
614
|
+
installCommand?: string;
|
|
615
|
+
framework?: string | null;
|
|
616
|
+
};
|
|
617
|
+
cloudflare?: {
|
|
618
|
+
outputDir?: string;
|
|
619
|
+
projectName?: string;
|
|
620
|
+
};
|
|
621
|
+
netlify?: {
|
|
622
|
+
outputDir?: string;
|
|
623
|
+
site?: string;
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
interface ResolvedFarmDeployConfig extends Omit<FarmDeployConfig, "output"> {
|
|
627
|
+
target?: FarmDeployTarget;
|
|
628
|
+
preset: FarmConfig["preset"];
|
|
629
|
+
outputDir: string;
|
|
630
|
+
}
|
|
631
|
+
interface FarmUserConfig extends Omit<FarmConfig, "vite" | "docs" | "env" | "layers"> {
|
|
632
|
+
/** Reusable Farm directories or installed packages, applied from left to right. */
|
|
633
|
+
extends?: readonly FarmLayerEntry[];
|
|
634
|
+
plugins?: FarmPlugin[];
|
|
635
|
+
integrations?: FarmIntegrationsUserConfig;
|
|
636
|
+
/**
|
|
637
|
+
* Farm-native authentication. `true` enables email/password auth with
|
|
638
|
+
* server helpers from `@farm.js/auth/server` and React APIs from
|
|
639
|
+
* `@farm.js/auth/client`.
|
|
640
|
+
*/
|
|
641
|
+
auth?: FarmAuthUserConfig;
|
|
642
|
+
/** Shared application data, route, ISR, and PPR cache. */
|
|
643
|
+
cache?: FarmCacheUserConfig;
|
|
644
|
+
migrations?: FarmMigrationsUserConfig;
|
|
645
|
+
/** Map portable cron schedules to ordinary GET API routes. */
|
|
646
|
+
cron?: FarmCronUserConfig | FarmCronResolvedConfig | false;
|
|
647
|
+
workflows?: FarmWorkflowsUserConfig | boolean;
|
|
648
|
+
preset?: FarmConfig["preset"];
|
|
649
|
+
deploy?: FarmDeployConfig;
|
|
650
|
+
docs?: FarmDocsUserConfig;
|
|
651
|
+
md?: FarmMarkdownUserConfig | boolean;
|
|
652
|
+
mdx?: FarmMdxUserConfig;
|
|
653
|
+
observability?: FarmObservabilityUserConfig;
|
|
654
|
+
trailingSlash?: boolean;
|
|
655
|
+
redirects?: () => Promise<RedirectConfig[]> | RedirectConfig[];
|
|
656
|
+
rewrites?: () => Promise<RewriteConfig[]> | RewriteConfig[];
|
|
657
|
+
headers?: () => Promise<HeaderConfig[]> | HeaderConfig[];
|
|
658
|
+
images?: ImageConfig;
|
|
659
|
+
publicDir?: string;
|
|
660
|
+
i18n?: FarmI18nUserConfig | false;
|
|
661
|
+
openapi?: OpenAPIConfig;
|
|
662
|
+
middleware?: FarmMiddlewareConfig;
|
|
663
|
+
routeRules?: FarmRouteRules;
|
|
664
|
+
context?: FarmConfig["context"];
|
|
665
|
+
serverActions?: FarmServerActionsConfig;
|
|
666
|
+
/** Build identifier used to detect and recover from deployment version skew. */
|
|
667
|
+
deploymentId?: string;
|
|
668
|
+
notFound?: NotFoundConfig;
|
|
669
|
+
output?: "standalone" | "static" | "export";
|
|
670
|
+
distDir?: string;
|
|
671
|
+
generateBuildId?: () => string | Promise<string>;
|
|
672
|
+
compress?: boolean;
|
|
673
|
+
devIndicators?: {
|
|
674
|
+
buildActivity?: boolean;
|
|
675
|
+
buildActivityPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
676
|
+
};
|
|
677
|
+
serverRuntimeConfig?: Record<string, any>;
|
|
678
|
+
publicRuntimeConfig?: Record<string, any>;
|
|
679
|
+
env?: FarmEnvConfig<any, any>;
|
|
680
|
+
typescript?: {
|
|
681
|
+
tsconfigPath?: string;
|
|
682
|
+
ignoreBuildErrors?: boolean;
|
|
683
|
+
};
|
|
684
|
+
vite?: UserConfig | ((config: UserConfig) => UserConfig);
|
|
685
|
+
[key: string]: any;
|
|
686
|
+
}
|
|
687
|
+
interface ResolvedFarmConfig extends Required<Omit<FarmUserConfig, "extends" | "plugins" | "vite" | "deploy" | "docs" | "md" | "mdx" | "migrations" | "cron" | "workflows" | "env" | "serverActions" | "devtools" | "images" | "i18n" | "auth" | "performance" | "security">> {
|
|
688
|
+
/** @internal Tracks whether `context` came from user/layer config instead of the default noop. */
|
|
689
|
+
[FARM_RESOLVED_CUSTOM_CONTEXT]?: boolean;
|
|
690
|
+
extends: readonly FarmLayerEntry[];
|
|
691
|
+
layers: ResolvedFarmLayer[];
|
|
692
|
+
plugins: FarmPlugin[];
|
|
693
|
+
vite: UserConfig;
|
|
694
|
+
deploy: ResolvedFarmDeployConfig;
|
|
695
|
+
docs: FarmDocsResolvedConfig;
|
|
696
|
+
md: FarmMarkdownResolvedConfig;
|
|
697
|
+
mdx: FarmMdxResolvedConfig;
|
|
698
|
+
migrations: ResolvedFarmMigrationsConfig;
|
|
699
|
+
cron: FarmCronResolvedConfig;
|
|
700
|
+
workflows: FarmWorkflowsResolvedConfig;
|
|
701
|
+
env: ResolvedFarmEnv;
|
|
702
|
+
serverActions: ResolvedFarmServerActionsConfig;
|
|
703
|
+
devtools: ResolvedFarmDevtoolsConfig;
|
|
704
|
+
images: ResolvedFarmImageConfig;
|
|
705
|
+
i18n: ResolvedFarmI18nConfig;
|
|
706
|
+
auth: ResolvedFarmAuthConfig;
|
|
707
|
+
performance: ResolvedFarmPerformanceConfig;
|
|
708
|
+
security: ResolvedFarmSecurityConfig;
|
|
709
|
+
routeRules: FarmRouteRules;
|
|
710
|
+
}
|
|
711
|
+
type FarmLayerConfig = Omit<FarmUserConfig, "root" | "outDir" | "distDir" | "deploy" | "output" | "preset" | "publicDir" | "generateBuildId" | "deploymentId">;
|
|
712
|
+
|
|
713
|
+
declare function normalizeDeployTarget(target?: FarmDeployTarget): FarmDeployTarget | undefined;
|
|
714
|
+
declare function getPresetForDeployTarget(target?: FarmDeployTarget): FarmConfig["preset"] | undefined;
|
|
715
|
+
declare function getDeployTargetForPreset(preset?: string): FarmDeployTarget | undefined;
|
|
716
|
+
declare function resolveDeployOutputPath(root: string, outputDir: string): string;
|
|
717
|
+
declare function resolveDeployConfig(config: Pick<FarmUserConfig, "deploy" | "preset" | "distDir">, overrides?: {
|
|
718
|
+
target?: FarmDeployTarget;
|
|
719
|
+
preset?: FarmConfig["preset"];
|
|
720
|
+
outputDir?: string;
|
|
721
|
+
}): ResolvedFarmDeployConfig;
|
|
722
|
+
declare function resolveMigrationsConfig(migrations: FarmMigrationsUserConfig | undefined): ResolvedFarmMigrationsConfig;
|
|
723
|
+
declare function resolveConfig(userConfig: FarmUserConfig, mode: "development" | "production"): Promise<ResolvedFarmConfig>;
|
|
724
|
+
declare function loadConfig(rootDir?: string, configPath?: string, mode?: string, loadEnvironment?: (typeof vite)["loadEnv"]): Promise<FarmUserConfig | undefined>;
|
|
725
|
+
|
|
726
|
+
interface FarmVitePluginOptions extends FarmConfig {
|
|
727
|
+
openapi?: FarmUserConfig["openapi"];
|
|
728
|
+
images?: FarmUserConfig["images"];
|
|
729
|
+
publicDir?: FarmUserConfig["publicDir"];
|
|
730
|
+
}
|
|
731
|
+
declare function farmI18nClientBridgePlugin(): Plugin;
|
|
732
|
+
interface FarmModuleAstNode {
|
|
733
|
+
type: string;
|
|
734
|
+
start: number;
|
|
735
|
+
end: number;
|
|
736
|
+
[key: string]: unknown;
|
|
737
|
+
}
|
|
738
|
+
declare function rewriteEarlySsrRelativeImports(options: {
|
|
739
|
+
code: string;
|
|
740
|
+
id: string;
|
|
741
|
+
root: string;
|
|
742
|
+
parse: (code: string) => FarmModuleAstNode;
|
|
743
|
+
}): string | null;
|
|
744
|
+
declare function farmPlugin(options?: FarmVitePluginOptions, initialPluginManager?: PluginManager): Plugin;
|
|
745
|
+
declare function defineConfig(config?: FarmVitePluginOptions): Promise<UserConfig>;
|
|
746
|
+
|
|
747
|
+
type MaybePromise$1<T> = T | Promise<T>;
|
|
748
|
+
interface PluginRequestContext {
|
|
749
|
+
set: (target: FarmRequest | Request, key: string, value: any, options?: {
|
|
750
|
+
exposeToPage?: boolean;
|
|
751
|
+
}) => void;
|
|
752
|
+
get: <T = any>(target: FarmRequest | Request, key: string) => T | undefined;
|
|
753
|
+
has: (target: FarmRequest | Request, key: string) => boolean;
|
|
754
|
+
delete: (target: FarmRequest | Request, key: string) => boolean;
|
|
755
|
+
clear: (target: FarmRequest | Request) => void;
|
|
756
|
+
getAll: (target: FarmRequest | Request, options?: {
|
|
757
|
+
exposedOnly?: boolean;
|
|
758
|
+
}) => Map<string, any>;
|
|
759
|
+
}
|
|
760
|
+
interface FarmRequestStore {
|
|
761
|
+
set(key: string, value: unknown, options?: {
|
|
762
|
+
exposeToPage?: boolean;
|
|
763
|
+
}): void;
|
|
764
|
+
get<T = unknown>(key: string): T | undefined;
|
|
765
|
+
has(key: string): boolean;
|
|
766
|
+
delete(key: string): boolean;
|
|
767
|
+
clear(): void;
|
|
768
|
+
snapshot(options?: {
|
|
769
|
+
exposedOnly?: boolean;
|
|
770
|
+
}): Map<string, unknown>;
|
|
771
|
+
}
|
|
772
|
+
interface FarmPluginContext {
|
|
773
|
+
config: FarmConfig;
|
|
774
|
+
viteServer?: ViteDevServer;
|
|
775
|
+
isDev: boolean;
|
|
776
|
+
isProd: boolean;
|
|
777
|
+
/** @deprecated Use `ctx.req` inside request hooks. */
|
|
778
|
+
requestContext: PluginRequestContext;
|
|
779
|
+
}
|
|
780
|
+
interface FarmRequestPluginContext extends FarmPluginContext {
|
|
781
|
+
/** Request-scoped values for the current hook invocation. */
|
|
782
|
+
readonly req: FarmRequestStore;
|
|
783
|
+
}
|
|
784
|
+
interface RouteDiscoveredPayload {
|
|
785
|
+
kind: "page" | "layout";
|
|
786
|
+
pattern: string;
|
|
787
|
+
modulePath: string;
|
|
788
|
+
}
|
|
789
|
+
interface RoutesGeneratedPayload {
|
|
790
|
+
routes: RouteDiscoveredPayload[];
|
|
791
|
+
pageCount: number;
|
|
792
|
+
layoutCount: number;
|
|
793
|
+
}
|
|
794
|
+
interface MiddlewareDiscoveredPayload {
|
|
795
|
+
path: string;
|
|
796
|
+
filePath: string;
|
|
797
|
+
handlerCount: number;
|
|
798
|
+
}
|
|
799
|
+
interface APIRouteDiscoveredPayload {
|
|
800
|
+
path: string;
|
|
801
|
+
filePath: string;
|
|
802
|
+
methods: string[];
|
|
803
|
+
}
|
|
804
|
+
interface RouteMatchPayload {
|
|
805
|
+
pathname: string;
|
|
806
|
+
method?: string;
|
|
807
|
+
}
|
|
808
|
+
interface RouteMatchResultPayload {
|
|
809
|
+
pathname: string;
|
|
810
|
+
matched: boolean;
|
|
811
|
+
routePattern: string | null;
|
|
812
|
+
params: Record<string, string>;
|
|
813
|
+
layoutPatterns: string[];
|
|
814
|
+
}
|
|
815
|
+
interface RenderLifecyclePayload {
|
|
816
|
+
pathname: string;
|
|
817
|
+
method: string;
|
|
818
|
+
routePattern: string | null;
|
|
819
|
+
params: Record<string, string>;
|
|
820
|
+
}
|
|
821
|
+
interface APIHandlerLifecyclePayload {
|
|
822
|
+
pathname: string;
|
|
823
|
+
method: string;
|
|
824
|
+
routePath?: string;
|
|
825
|
+
}
|
|
826
|
+
interface ErrorLifecyclePayload {
|
|
827
|
+
phase: string;
|
|
828
|
+
error: unknown;
|
|
829
|
+
meta?: Record<string, unknown>;
|
|
830
|
+
}
|
|
831
|
+
interface HMRUpdatePayload {
|
|
832
|
+
file: string;
|
|
833
|
+
modules: string[];
|
|
834
|
+
}
|
|
835
|
+
interface BundleLifecyclePayload {
|
|
836
|
+
root: string;
|
|
837
|
+
preset: string;
|
|
838
|
+
universal: boolean;
|
|
839
|
+
distDir: string;
|
|
840
|
+
outputDir?: string;
|
|
841
|
+
}
|
|
842
|
+
interface BundleResultPayload extends BundleLifecyclePayload {
|
|
843
|
+
success: boolean;
|
|
844
|
+
}
|
|
845
|
+
interface NitroBuildLifecyclePayload {
|
|
846
|
+
root: string;
|
|
847
|
+
preset: string;
|
|
848
|
+
distDir: string;
|
|
849
|
+
outputDir: string;
|
|
850
|
+
}
|
|
851
|
+
interface ShutdownPayload {
|
|
852
|
+
reason: string;
|
|
853
|
+
}
|
|
854
|
+
type FarmPluginRuntimeKind = "request" | "page" | "api" | "action" | "integration" | "docs" | "asset" | (string & {});
|
|
855
|
+
interface FarmPluginRouteRuntimePayload {
|
|
856
|
+
pathname: string;
|
|
857
|
+
pattern?: string | null;
|
|
858
|
+
params?: Record<string, string>;
|
|
859
|
+
}
|
|
860
|
+
interface FarmPluginSetupContext extends FarmPluginContext {
|
|
861
|
+
env: ResolvedFarmEnv;
|
|
862
|
+
}
|
|
863
|
+
interface FarmPluginStateContext<TState = unknown> extends FarmPluginContext {
|
|
864
|
+
state: TState;
|
|
865
|
+
}
|
|
866
|
+
interface FarmPluginRuntimeBaseEvent<TState = unknown> extends FarmPluginStateContext<TState> {
|
|
867
|
+
request: Request;
|
|
868
|
+
/** Request-scoped values shared by plugin hooks. */
|
|
869
|
+
req: FarmRequestStore;
|
|
870
|
+
kind: FarmPluginRuntimeKind;
|
|
871
|
+
route?: FarmPluginRouteRuntimePayload;
|
|
872
|
+
signal: AbortSignal;
|
|
873
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
874
|
+
}
|
|
875
|
+
type FarmPluginRuntimeContextEvent<TState = unknown> = FarmPluginRuntimeBaseEvent<TState>;
|
|
876
|
+
interface FarmPluginRuntimeBeforeEvent<TState = unknown, TRequestContext extends object = Record<string, unknown>> extends FarmPluginRuntimeBaseEvent<TState> {
|
|
877
|
+
ctx: Readonly<TRequestContext>;
|
|
878
|
+
}
|
|
879
|
+
interface FarmPluginRuntimeAfterEvent<TState = unknown, TRequestContext extends object = Record<string, unknown>> extends FarmPluginRuntimeBeforeEvent<TState, TRequestContext> {
|
|
880
|
+
response: Response;
|
|
881
|
+
durationMs: number;
|
|
882
|
+
}
|
|
883
|
+
interface FarmPluginRuntimeErrorEvent<TState = unknown, TRequestContext extends object = Record<string, unknown>> extends FarmPluginRuntimeBeforeEvent<TState, TRequestContext> {
|
|
884
|
+
error: unknown;
|
|
885
|
+
durationMs: number;
|
|
886
|
+
}
|
|
887
|
+
type FarmPluginRuntimeStartEvent<TState = unknown> = FarmPluginStateContext<TState>;
|
|
888
|
+
interface FarmPluginRuntimeCloseEvent<TState = unknown> extends FarmPluginStateContext<TState>, ShutdownPayload {
|
|
889
|
+
}
|
|
890
|
+
interface FarmPluginRuntimeHooks<TState = unknown, TRequestContext extends object = Record<string, unknown>> {
|
|
891
|
+
start?(event: FarmPluginRuntimeStartEvent<TState>): MaybePromise$1<void>;
|
|
892
|
+
context?(event: FarmPluginRuntimeContextEvent<TState>): MaybePromise$1<TRequestContext>;
|
|
893
|
+
before?(event: FarmPluginRuntimeBeforeEvent<TState, TRequestContext>): MaybePromise$1<Request | Response | void>;
|
|
894
|
+
after?(event: FarmPluginRuntimeAfterEvent<TState, TRequestContext>): MaybePromise$1<Response | void>;
|
|
895
|
+
error?(event: FarmPluginRuntimeErrorEvent<TState, TRequestContext>): MaybePromise$1<void>;
|
|
896
|
+
close?(event: FarmPluginRuntimeCloseEvent<TState>): MaybePromise$1<void>;
|
|
897
|
+
}
|
|
898
|
+
interface FarmPluginRuntimeRequestOptions {
|
|
899
|
+
kind?: FarmPluginRuntimeKind;
|
|
900
|
+
route?: FarmPluginRouteRuntimePayload;
|
|
901
|
+
waitUntil?: (promise: Promise<unknown>) => void;
|
|
902
|
+
}
|
|
903
|
+
type FarmPluginRuntimeRequestHandler = (request: Request) => MaybePromise$1<Response>;
|
|
904
|
+
interface FarmPluginRuntimeSession {
|
|
905
|
+
request: Request;
|
|
906
|
+
response?: Response;
|
|
907
|
+
ctx: Readonly<Record<string, unknown>>;
|
|
908
|
+
startedAt: number;
|
|
909
|
+
options: FarmPluginRuntimeRequestOptions;
|
|
910
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
911
|
+
}
|
|
912
|
+
type FarmPluginDiscoveredRoute = RouteDiscoveredPayload | ({
|
|
913
|
+
kind: "middleware";
|
|
914
|
+
} & MiddlewareDiscoveredPayload) | ({
|
|
915
|
+
kind: "api";
|
|
916
|
+
} & APIRouteDiscoveredPayload);
|
|
917
|
+
interface FarmPluginRouterHooks<TState = unknown> {
|
|
918
|
+
discovered?(route: FarmPluginDiscoveredRoute, context: FarmPluginStateContext<TState>): MaybePromise$1<void>;
|
|
919
|
+
generated?(routes: RoutesGeneratedPayload, context: FarmPluginStateContext<TState>): MaybePromise$1<void>;
|
|
920
|
+
before?(route: RouteMatchPayload, context: FarmPluginStateContext<TState>): MaybePromise$1<void>;
|
|
921
|
+
after?(result: RouteMatchResultPayload, context: FarmPluginStateContext<TState>): MaybePromise$1<void>;
|
|
922
|
+
}
|
|
923
|
+
interface FarmPluginRenderHooks<TState = unknown> {
|
|
924
|
+
before?(render: RenderLifecyclePayload, context: FarmPluginStateContext<TState>): MaybePromise$1<void>;
|
|
925
|
+
html?(html: string, render: RenderLifecyclePayload, context: FarmPluginStateContext<TState>): MaybePromise$1<string | void>;
|
|
926
|
+
}
|
|
927
|
+
interface FarmPluginBuildHooks<TState = unknown> {
|
|
928
|
+
before?(bundle: BundleLifecyclePayload, context: FarmPluginStateContext<TState>): MaybePromise$1<void>;
|
|
929
|
+
configure?(buildConfig: any, context: FarmPluginStateContext<TState>): MaybePromise$1<any>;
|
|
930
|
+
after?(result: BundleResultPayload, context: FarmPluginStateContext<TState>): MaybePromise$1<void>;
|
|
931
|
+
}
|
|
932
|
+
interface FarmPluginDevHooks<TState = unknown> {
|
|
933
|
+
server?(viteServer: ViteDevServer, context: FarmPluginStateContext<TState>): MaybePromise$1<void>;
|
|
934
|
+
update?(update: HMRUpdatePayload, context: FarmPluginStateContext<TState>): MaybePromise$1<void>;
|
|
935
|
+
}
|
|
936
|
+
interface FarmPluginClientConfig<TState = unknown, TPublic = undefined> extends FarmClientPlugin<TState, TPublic> {
|
|
937
|
+
/** Explicitly public, JSON-safe data embedded in the browser bundle. */
|
|
938
|
+
public?: TPublic;
|
|
939
|
+
}
|
|
940
|
+
interface FarmPlugin<TState = any, TRequestContext extends object = Record<string, unknown>, TClientState = any, TClientPublic = any> {
|
|
941
|
+
name: string;
|
|
942
|
+
version?: string;
|
|
943
|
+
enforce?: "pre" | "post";
|
|
944
|
+
/** Transform Farm config before it is resolved. */
|
|
945
|
+
configure?: (config: FarmConfig, context: FarmPluginContext) => MaybePromise$1<FarmConfig | void>;
|
|
946
|
+
/** Initialize private plugin state once for this plugin manager. */
|
|
947
|
+
setup?: (context: FarmPluginSetupContext) => MaybePromise$1<TState>;
|
|
948
|
+
runtime?: FarmPluginRuntimeHooks<TState, TRequestContext>;
|
|
949
|
+
router?: FarmPluginRouterHooks<TState>;
|
|
950
|
+
render?: FarmPluginRenderHooks<TState>;
|
|
951
|
+
build?: FarmPluginBuildHooks<TState>;
|
|
952
|
+
dev?: FarmPluginDevHooks<TState>;
|
|
953
|
+
/** Optional browser lifecycle for this logical plugin. */
|
|
954
|
+
client?: FarmPluginClientConfig<TClientState, TClientPublic>;
|
|
955
|
+
/** @deprecated Use `setup` instead. */
|
|
956
|
+
init?: (context: FarmPluginContext) => void | Promise<void>;
|
|
957
|
+
/** @deprecated Use `runtime.start` instead. */
|
|
958
|
+
ready?: (context: FarmPluginContext) => void | Promise<void>;
|
|
959
|
+
/** @deprecated Use `dev.server` instead. */
|
|
960
|
+
devServerCreated?: (viteServer: ViteDevServer, context: FarmPluginContext) => void | Promise<void>;
|
|
961
|
+
/** @deprecated Use `configure` instead. */
|
|
962
|
+
config?: (config: FarmConfig, context: FarmPluginContext) => FarmConfig | Promise<FarmConfig>;
|
|
963
|
+
configResolved?: (config: FarmConfig, context: FarmPluginContext) => void | Promise<void>;
|
|
964
|
+
/** @deprecated Use `build.before` instead. */
|
|
965
|
+
buildStart?: (context: FarmPluginContext) => void | Promise<void>;
|
|
966
|
+
/** @deprecated Use `build.after` instead. */
|
|
967
|
+
buildEnd?: (context: FarmPluginContext) => void | Promise<void>;
|
|
968
|
+
/** @deprecated Use `router.discovered` instead. */
|
|
969
|
+
routeDiscovered?: (route: RouteDiscoveredPayload, context: FarmPluginContext) => void | Promise<void>;
|
|
970
|
+
/** @deprecated Use `router.generated` instead. */
|
|
971
|
+
routesGenerated?: (routes: RoutesGeneratedPayload, context: FarmPluginContext) => void | Promise<void>;
|
|
972
|
+
/** @deprecated Use `router.discovered` instead. */
|
|
973
|
+
middlewareDiscovered?: (middleware: MiddlewareDiscoveredPayload, context: FarmPluginContext) => void | Promise<void>;
|
|
974
|
+
/** @deprecated Use `router.discovered` instead. */
|
|
975
|
+
apiRouteDiscovered?: (route: APIRouteDiscoveredPayload, context: FarmPluginContext) => void | Promise<void>;
|
|
976
|
+
/** @deprecated Use `router.before` instead. */
|
|
977
|
+
beforeRouteMatch?: (route: RouteMatchPayload, context: FarmPluginContext) => void | Promise<void>;
|
|
978
|
+
/** @deprecated Use `router.after` instead. */
|
|
979
|
+
afterRouteMatch?: (result: RouteMatchResultPayload, context: FarmPluginContext) => void | Promise<void>;
|
|
980
|
+
/** @deprecated Use `render.before` instead. */
|
|
981
|
+
beforeRender?: (render: RenderLifecyclePayload, context: FarmPluginContext) => void | Promise<void>;
|
|
982
|
+
/** @deprecated Use `render.html` instead. */
|
|
983
|
+
afterRender?: (html: string, render: RenderLifecyclePayload, context: FarmPluginContext) => string | Promise<string> | void | Promise<void>;
|
|
984
|
+
/** @deprecated Use `runtime.before` instead. */
|
|
985
|
+
beforeApiHandler?: (request: Request, api: APIHandlerLifecyclePayload, context: FarmRequestPluginContext) => Request | Promise<Request> | void | Promise<void>;
|
|
986
|
+
/** @deprecated Use `runtime.after` instead. */
|
|
987
|
+
afterApiHandler?: (response: Response, api: APIHandlerLifecyclePayload, context: FarmPluginContext) => Response | Promise<Response> | void | Promise<void>;
|
|
988
|
+
onError?: (error: ErrorLifecyclePayload, context: FarmPluginContext) => void | Promise<void>;
|
|
989
|
+
/** @deprecated Use `dev.update` instead. */
|
|
990
|
+
hmrUpdate?: (update: HMRUpdatePayload, context: FarmPluginContext) => void | Promise<void>;
|
|
991
|
+
/** @deprecated Use `build.before` instead. */
|
|
992
|
+
beforeBundle?: (bundle: BundleLifecyclePayload, context: FarmPluginContext) => void | Promise<void>;
|
|
993
|
+
/** @deprecated Use `build.after` instead. */
|
|
994
|
+
afterBundle?: (result: BundleResultPayload, context: FarmPluginContext) => void | Promise<void>;
|
|
995
|
+
/** @deprecated Use `build.configure` instead. */
|
|
996
|
+
beforeNitroBuild?: (nitroConfig: any, context: FarmPluginContext) => any | Promise<any>;
|
|
997
|
+
afterNitroBuild?: (payload: NitroBuildLifecyclePayload, context: FarmPluginContext) => void | Promise<void>;
|
|
998
|
+
/** @deprecated Use `runtime.close` instead. */
|
|
999
|
+
shutdown?: (payload: ShutdownPayload, context: FarmPluginContext) => void | Promise<void>;
|
|
1000
|
+
/** @deprecated Use the Web Request based `runtime.before` hook instead. */
|
|
1001
|
+
beforeRequest?: (req: FarmRequest, res: FarmResponse, context: FarmRequestPluginContext) => void | Promise<void>;
|
|
1002
|
+
/** @deprecated Use the Web Response based `runtime.after` hook instead. */
|
|
1003
|
+
afterResponse?: (req: FarmRequest, res: FarmResponse, context: FarmRequestPluginContext) => void | Promise<void>;
|
|
1004
|
+
/** @deprecated Use `render.html` instead. */
|
|
1005
|
+
transformHTML?: (html: string, context: FarmPluginContext) => string | Promise<string>;
|
|
1006
|
+
/** @deprecated Use `render.before` or `render.html` instead. */
|
|
1007
|
+
transformPage?: (component: any, context: FarmPluginContext) => any | Promise<any>;
|
|
1008
|
+
}
|
|
1009
|
+
declare class PluginManager {
|
|
1010
|
+
private plugins;
|
|
1011
|
+
private hookPresence;
|
|
1012
|
+
private runtimeHookPresence;
|
|
1013
|
+
private context;
|
|
1014
|
+
private pluginStates;
|
|
1015
|
+
private setupComplete;
|
|
1016
|
+
private initialized;
|
|
1017
|
+
private runtimeReady;
|
|
1018
|
+
private runtimeClosed;
|
|
1019
|
+
private runtimeStartPromise?;
|
|
1020
|
+
private runtimeClosePromise?;
|
|
1021
|
+
private runtimeRequestContexts;
|
|
1022
|
+
private failedRuntimeSessions;
|
|
1023
|
+
constructor(context: Omit<FarmPluginContext, "requestContext">);
|
|
1024
|
+
private createRequestHookContext;
|
|
1025
|
+
private copyRequestStore;
|
|
1026
|
+
private copyRuntimeRequestContext;
|
|
1027
|
+
private createRuntimeBaseEvent;
|
|
1028
|
+
private createRuntimeRequestContext;
|
|
1029
|
+
private runRuntimeErrorHooks;
|
|
1030
|
+
private createStateHookContext;
|
|
1031
|
+
private getPluginHooks;
|
|
1032
|
+
private getHookContext;
|
|
1033
|
+
addPlugin(plugin: FarmPlugin): void;
|
|
1034
|
+
addPlugins(plugins: FarmPlugin[]): void;
|
|
1035
|
+
getPlugins(): FarmPlugin[];
|
|
1036
|
+
getSortedPlugins(): FarmPlugin[];
|
|
1037
|
+
hasHook(hookName: keyof FarmPlugin): boolean;
|
|
1038
|
+
hasRuntimeHook(hookName: "context" | "before" | "after" | "error"): boolean;
|
|
1039
|
+
hasRuntimeRequestHooks(): boolean;
|
|
1040
|
+
copyRequestContext(source: FarmRequest | Request, target: FarmRequest | Request): void;
|
|
1041
|
+
setupPlugins(): Promise<void>;
|
|
1042
|
+
startRuntime(): Promise<void>;
|
|
1043
|
+
closeRuntime(reason?: string): Promise<void>;
|
|
1044
|
+
beginRuntimeRequest(request: Request, options?: FarmPluginRuntimeRequestOptions): Promise<FarmPluginRuntimeSession>;
|
|
1045
|
+
endRuntimeRequest(session: FarmPluginRuntimeSession, initialResponse: Response): Promise<Response>;
|
|
1046
|
+
failRuntimeRequest(session: FarmPluginRuntimeSession, error: unknown): Promise<void>;
|
|
1047
|
+
runRuntimeRequest(request: Request, handler: FarmPluginRuntimeRequestHandler, options?: FarmPluginRuntimeRequestOptions): Promise<Response>;
|
|
1048
|
+
runHook<K extends keyof FarmPlugin>(hookName: K, ...args: any[]): Promise<any>;
|
|
1049
|
+
runHookSerial<K extends keyof FarmPlugin>(hookName: K, initialValue: any, ...args: any[]): Promise<any>;
|
|
1050
|
+
runHookParallel<K extends keyof FarmPlugin>(hookName: K, ...args: any[]): Promise<boolean>;
|
|
1051
|
+
updateContext(updates: Partial<FarmPluginContext>): void;
|
|
1052
|
+
}
|
|
1053
|
+
declare function definePlugin<TState = undefined, TRequestContext extends object = Record<string, never>, TClientState = unknown, TClientPublic = undefined>(plugin: FarmPlugin<TState, TRequestContext, TClientState, TClientPublic>): FarmPlugin<TState, TRequestContext, TClientState, TClientPublic>;
|
|
1054
|
+
|
|
1055
|
+
type FarmIntegrationCategory = "auth" | "payment" | "monitoring" | "logging" | (string & {});
|
|
1056
|
+
/** @deprecated Use FarmIntegrationCategory instead. */
|
|
1057
|
+
type FarmIntegrationSlot = FarmIntegrationCategory;
|
|
1058
|
+
type FarmIntegrationRouteParamValue = string | string[];
|
|
1059
|
+
type FarmIntegrationRouteParams = Record<string, FarmIntegrationRouteParamValue>;
|
|
1060
|
+
type FarmIntegrationRouteMethod = FarmIntegrationAPIMethod | Lowercase<FarmIntegrationAPIMethod> | "ALL" | "all";
|
|
1061
|
+
type FarmIntegrationRouteInputSource = "body" | "query";
|
|
1062
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
1063
|
+
type FarmIntegrationValidationPathSegment = PropertyKey | {
|
|
1064
|
+
readonly key: PropertyKey;
|
|
1065
|
+
};
|
|
1066
|
+
interface FarmIntegrationRouteInput<TBody = unknown, TQuery = unknown> {
|
|
1067
|
+
body?: TBody;
|
|
1068
|
+
query?: TQuery;
|
|
1069
|
+
}
|
|
1070
|
+
interface FarmIntegrationValidationIssue {
|
|
1071
|
+
source: FarmIntegrationRouteInputSource;
|
|
1072
|
+
path?: readonly (string | number)[];
|
|
1073
|
+
code?: string;
|
|
1074
|
+
message: string;
|
|
1075
|
+
}
|
|
1076
|
+
interface FarmIntegrationValidationErrorLike {
|
|
1077
|
+
issues?: readonly {
|
|
1078
|
+
path?: readonly FarmIntegrationValidationPathSegment[];
|
|
1079
|
+
code?: string;
|
|
1080
|
+
message?: string;
|
|
1081
|
+
}[];
|
|
1082
|
+
message?: string;
|
|
1083
|
+
}
|
|
1084
|
+
type FarmIntegrationValidationResult<TValue> = {
|
|
1085
|
+
success: true;
|
|
1086
|
+
data: TValue;
|
|
1087
|
+
} | {
|
|
1088
|
+
success: false;
|
|
1089
|
+
error: FarmIntegrationValidationErrorLike;
|
|
1090
|
+
};
|
|
1091
|
+
type FarmIntegrationStandardValidationResult<TValue> = {
|
|
1092
|
+
value: TValue;
|
|
1093
|
+
} | {
|
|
1094
|
+
issues: readonly {
|
|
1095
|
+
path?: readonly FarmIntegrationValidationPathSegment[];
|
|
1096
|
+
code?: string;
|
|
1097
|
+
message: string;
|
|
1098
|
+
}[];
|
|
1099
|
+
};
|
|
1100
|
+
interface FarmIntegrationInputSchema<TValue = unknown> {
|
|
1101
|
+
_output?: TValue;
|
|
1102
|
+
parse?(value: unknown): MaybePromise<TValue>;
|
|
1103
|
+
safeParse?(value: unknown): MaybePromise<FarmIntegrationValidationResult<TValue>>;
|
|
1104
|
+
safeParseAsync?(value: unknown): Promise<FarmIntegrationValidationResult<TValue>>;
|
|
1105
|
+
"~standard"?: {
|
|
1106
|
+
validate(value: unknown): MaybePromise<FarmIntegrationStandardValidationResult<TValue>>;
|
|
1107
|
+
types?: {
|
|
1108
|
+
output: TValue;
|
|
1109
|
+
};
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
interface FarmIntegrationRouteInputSchemas<TBody = unknown, TQuery = unknown> {
|
|
1113
|
+
body?: FarmIntegrationInputSchema<TBody>;
|
|
1114
|
+
query?: FarmIntegrationInputSchema<TQuery>;
|
|
1115
|
+
}
|
|
1116
|
+
/** @deprecated Use `FarmRequestStore` and access it through `ctx.req`. */
|
|
1117
|
+
type FarmIntegrationRequestContextStore = FarmRequestStore;
|
|
1118
|
+
declare const FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = "farm.integration.internalDispatch";
|
|
1119
|
+
type FarmIntegrationRouteDb<TSchema extends FarmIntegrationSchema | undefined> = InferFarmIntegrationOrmClient<TSchema>;
|
|
1120
|
+
interface FarmIntegrationRouteStorageArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
|
|
1121
|
+
getClient(): Promise<unknown | undefined>;
|
|
1122
|
+
getOrm(): Promise<FarmIntegrationRouteDb<TSchema>>;
|
|
1123
|
+
}
|
|
1124
|
+
interface FarmIntegrationRouteArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
|
|
1125
|
+
db: FarmIntegrationRouteDb<TSchema>;
|
|
1126
|
+
getDb(): Promise<FarmIntegrationRouteDb<TSchema>>;
|
|
1127
|
+
storage: FarmIntegrationRouteStorageArgs<TSchema>;
|
|
1128
|
+
}
|
|
1129
|
+
interface FarmIntegrationConfigContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
|
|
1130
|
+
key: string;
|
|
1131
|
+
integration: FarmIntegration<TSchema, any>;
|
|
1132
|
+
appConfig: FarmPluginContext["config"];
|
|
1133
|
+
/** Alias for appConfig. */
|
|
1134
|
+
config: FarmPluginContext["config"];
|
|
1135
|
+
args: FarmIntegrationRouteArgs<TSchema>;
|
|
1136
|
+
env: Record<string, string | undefined>;
|
|
1137
|
+
isDev: boolean;
|
|
1138
|
+
isProd: boolean;
|
|
1139
|
+
}
|
|
1140
|
+
interface FarmIntegrationConfigDefinition<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
|
|
1141
|
+
schema?: FarmIntegrationInputSchema<TConfig>;
|
|
1142
|
+
env?: Record<string, string | readonly string[]>;
|
|
1143
|
+
defaults?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise<Partial<TConfig>>);
|
|
1144
|
+
input?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise<Partial<TConfig>>);
|
|
1145
|
+
resolve?(context: FarmIntegrationConfigContext<TSchema>): MaybePromise<TConfig | Partial<TConfig> | undefined>;
|
|
1146
|
+
}
|
|
1147
|
+
type FarmIntegrationConfigInput<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationInputSchema<TConfig> | FarmIntegrationConfigDefinition<TConfig, TSchema>;
|
|
1148
|
+
type FarmIntegrationLifecycleLogLevel = "info" | "warn" | "error";
|
|
1149
|
+
interface FarmIntegrationLifecycleLogger {
|
|
1150
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
1151
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
1152
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
1153
|
+
}
|
|
1154
|
+
interface FarmIntegrationLifecycleContext<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationConfigContext<TSchema> {
|
|
1155
|
+
integration: FarmIntegration<TSchema, TConfig>;
|
|
1156
|
+
integrationConfig: TConfig;
|
|
1157
|
+
log: FarmIntegrationLifecycleLogger;
|
|
1158
|
+
reason?: string;
|
|
1159
|
+
cleanup(callback?: () => MaybePromise<void>): Promise<void>;
|
|
1160
|
+
}
|
|
1161
|
+
type FarmIntegrationLifecycleHook<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationLifecycleContext<TConfig, TSchema>) => MaybePromise<void>;
|
|
1162
|
+
/**
|
|
1163
|
+
* Small per-call integration metadata. Values received over HTTP are
|
|
1164
|
+
* client-controlled and should be validated before authorization decisions.
|
|
1165
|
+
*/
|
|
1166
|
+
type FarmIntegrationData = Record<string, unknown>;
|
|
1167
|
+
interface FarmIntegrationHandlerContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
|
|
1168
|
+
request: Request;
|
|
1169
|
+
requestId: string;
|
|
1170
|
+
url: URL;
|
|
1171
|
+
pathname: string;
|
|
1172
|
+
method: string;
|
|
1173
|
+
params: FarmIntegrationRouteParams;
|
|
1174
|
+
input: FarmIntegrationRouteInput<TBody, TQuery>;
|
|
1175
|
+
args: FarmIntegrationRouteArgs<TSchema>;
|
|
1176
|
+
data: FarmIntegrationData;
|
|
1177
|
+
integration: {
|
|
1178
|
+
category: FarmIntegrationCategory;
|
|
1179
|
+
/** @deprecated Use category instead. */
|
|
1180
|
+
slot: FarmIntegrationCategory;
|
|
1181
|
+
type: string;
|
|
1182
|
+
instance: unknown;
|
|
1183
|
+
};
|
|
1184
|
+
route: {
|
|
1185
|
+
kind: "route" | "middleware";
|
|
1186
|
+
path: string;
|
|
1187
|
+
methods: readonly string[];
|
|
1188
|
+
};
|
|
1189
|
+
req: FarmRequestStore;
|
|
1190
|
+
/** @deprecated Use `req` instead. */
|
|
1191
|
+
requestContext: FarmRequestStore;
|
|
1192
|
+
config: FarmPluginContext["config"];
|
|
1193
|
+
isDev: boolean;
|
|
1194
|
+
isProd: boolean;
|
|
1195
|
+
}
|
|
1196
|
+
interface FarmIntegrationRouteHookContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationHandlerContext<TBody, TQuery, TSchema> {
|
|
1197
|
+
response?: Response;
|
|
1198
|
+
}
|
|
1199
|
+
type FarmIntegrationRouteHook<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
|
|
1200
|
+
bivarianceHack(request: Request, context: FarmIntegrationRouteHookContext<TBody, TQuery, TSchema>): Promise<Response | void> | Response | void;
|
|
1201
|
+
}["bivarianceHack"];
|
|
1202
|
+
interface FarmIntegrationRoute<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
|
|
1203
|
+
path: string;
|
|
1204
|
+
method?: FarmIntegrationRouteMethod;
|
|
1205
|
+
methods?: readonly FarmIntegrationRouteMethod[];
|
|
1206
|
+
middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
|
|
1207
|
+
before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
|
|
1208
|
+
after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
|
|
1209
|
+
rawBody?: boolean;
|
|
1210
|
+
bodyFormat?: FarmIntegrationAPIBodyFormat;
|
|
1211
|
+
body?: FarmIntegrationInputSchema<TBody>;
|
|
1212
|
+
query?: FarmIntegrationInputSchema<TQuery>;
|
|
1213
|
+
input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
|
|
1214
|
+
handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
|
|
1215
|
+
}
|
|
1216
|
+
interface FarmTypedIntegrationRoute<TPath extends string = string, TBody = never, TQuery = never, TResponse = unknown, TServer extends boolean = false, TMethod extends FarmIntegrationAPIMethod = FarmIntegrationAPIMethod, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationRoute<TBody, TQuery, TSchema> {
|
|
1217
|
+
path: TPath;
|
|
1218
|
+
method: TMethod;
|
|
1219
|
+
__operation: FarmIntegrationAPIOperation<TBody, TQuery, TResponse, TServer, TMethod>;
|
|
1220
|
+
}
|
|
1221
|
+
interface FarmIntegrationRouteMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
|
|
1222
|
+
handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
|
|
1223
|
+
}
|
|
1224
|
+
interface FarmIntegrationMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
|
|
1225
|
+
matcher?: string | string[];
|
|
1226
|
+
handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
|
|
1227
|
+
}
|
|
1228
|
+
interface FarmIntegrationProviderProps {
|
|
1229
|
+
children: ReactNode;
|
|
1230
|
+
}
|
|
1231
|
+
interface FarmIntegrationProvider {
|
|
1232
|
+
name: string;
|
|
1233
|
+
type: string;
|
|
1234
|
+
props?: Record<string, unknown>;
|
|
1235
|
+
component?: ComponentType<FarmIntegrationProviderProps>;
|
|
1236
|
+
}
|
|
1237
|
+
interface FarmIntegrationDocumentNavigation {
|
|
1238
|
+
matcher: string | readonly string[];
|
|
1239
|
+
}
|
|
1240
|
+
type FarmIntegrationSchemaFieldType = "id" | "uuid" | "string" | "text" | "boolean" | "integer" | "number" | "datetime" | "json" | "enum";
|
|
1241
|
+
interface FarmIntegrationSchemaReference {
|
|
1242
|
+
model: string;
|
|
1243
|
+
field: string;
|
|
1244
|
+
relation?: "belongsTo" | "hasOne" | "hasMany";
|
|
1245
|
+
onDelete?: "cascade" | "restrict" | "setNull" | "noAction";
|
|
1246
|
+
enforced?: "db" | "app" | "none";
|
|
1247
|
+
}
|
|
1248
|
+
interface FarmIntegrationSchemaField {
|
|
1249
|
+
type: FarmIntegrationSchemaFieldType;
|
|
1250
|
+
name?: string;
|
|
1251
|
+
description?: string;
|
|
1252
|
+
required?: boolean;
|
|
1253
|
+
nullable?: boolean;
|
|
1254
|
+
primaryKey?: boolean;
|
|
1255
|
+
unique?: boolean;
|
|
1256
|
+
index?: boolean;
|
|
1257
|
+
list?: boolean;
|
|
1258
|
+
default?: unknown;
|
|
1259
|
+
values?: readonly string[];
|
|
1260
|
+
reference?: FarmIntegrationSchemaReference;
|
|
1261
|
+
meta?: Record<string, unknown>;
|
|
1262
|
+
}
|
|
1263
|
+
interface FarmIntegrationSchemaConstraint {
|
|
1264
|
+
type: "unique" | "index";
|
|
1265
|
+
fields: readonly string[];
|
|
1266
|
+
name?: string;
|
|
1267
|
+
meta?: Record<string, unknown>;
|
|
1268
|
+
}
|
|
1269
|
+
interface FarmIntegrationSchemaModel {
|
|
1270
|
+
name?: string;
|
|
1271
|
+
description?: string;
|
|
1272
|
+
fields: Record<string, FarmIntegrationSchemaField>;
|
|
1273
|
+
constraints?: readonly FarmIntegrationSchemaConstraint[];
|
|
1274
|
+
meta?: Record<string, unknown>;
|
|
1275
|
+
}
|
|
1276
|
+
interface FarmIntegrationSchemaModelExtension {
|
|
1277
|
+
name?: string;
|
|
1278
|
+
description?: string;
|
|
1279
|
+
fields?: Record<string, FarmIntegrationSchemaField>;
|
|
1280
|
+
constraints?: readonly FarmIntegrationSchemaConstraint[];
|
|
1281
|
+
meta?: Record<string, unknown>;
|
|
1282
|
+
}
|
|
1283
|
+
interface FarmIntegrationSchemaModelOverride {
|
|
1284
|
+
name?: string;
|
|
1285
|
+
description?: string;
|
|
1286
|
+
fields?: Record<string, Partial<FarmIntegrationSchemaField>>;
|
|
1287
|
+
constraints?: readonly FarmIntegrationSchemaConstraint[];
|
|
1288
|
+
meta?: Record<string, unknown>;
|
|
1289
|
+
}
|
|
1290
|
+
interface FarmIntegrationSchema {
|
|
1291
|
+
models: Record<string, FarmIntegrationSchemaModel>;
|
|
1292
|
+
meta?: Record<string, unknown>;
|
|
1293
|
+
extend?: Record<string, FarmIntegrationSchemaModelExtension>;
|
|
1294
|
+
override?: Record<string, FarmIntegrationSchemaModelOverride>;
|
|
1295
|
+
}
|
|
1296
|
+
declare function defineIntegrationSchema<TSchema extends FarmIntegrationSchema>(schema: TSchema): TSchema;
|
|
1297
|
+
type FarmIntegrationLogPhase = "registered" | "validate" | "setup" | "ready" | "dispose" | "request:start" | "request:end" | "request:error";
|
|
1298
|
+
interface FarmIntegrationLogEvent {
|
|
1299
|
+
category: FarmIntegrationCategory;
|
|
1300
|
+
/** @deprecated Use category instead. */
|
|
1301
|
+
slot: FarmIntegrationCategory;
|
|
1302
|
+
type: string;
|
|
1303
|
+
phase: FarmIntegrationLogPhase;
|
|
1304
|
+
route?: {
|
|
1305
|
+
kind: "route" | "middleware";
|
|
1306
|
+
path: string;
|
|
1307
|
+
methods: readonly string[];
|
|
1308
|
+
};
|
|
1309
|
+
requestId?: string;
|
|
1310
|
+
request?: Request;
|
|
1311
|
+
response?: Response;
|
|
1312
|
+
error?: unknown;
|
|
1313
|
+
durationMs?: number;
|
|
1314
|
+
level?: FarmIntegrationLifecycleLogLevel;
|
|
1315
|
+
message?: string;
|
|
1316
|
+
meta?: Record<string, unknown>;
|
|
1317
|
+
context: Map<string, unknown>;
|
|
1318
|
+
}
|
|
1319
|
+
type FarmIntegrationLogger = (event: FarmIntegrationLogEvent) => void | Promise<void>;
|
|
1320
|
+
interface FarmIntegration<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined, TConfig = unknown> {
|
|
1321
|
+
readonly kind: "farm-integration";
|
|
1322
|
+
category: FarmIntegrationCategory;
|
|
1323
|
+
/** @deprecated Use category instead. */
|
|
1324
|
+
slot?: FarmIntegrationCategory;
|
|
1325
|
+
type: string;
|
|
1326
|
+
instance: unknown;
|
|
1327
|
+
/** Set to false when a platform adapter owns this integration's production routes. */
|
|
1328
|
+
serverRuntime?: boolean;
|
|
1329
|
+
api?: FarmIntegrationAPI;
|
|
1330
|
+
schema?: TSchema;
|
|
1331
|
+
config?: FarmIntegrationConfigInput<TConfig, TSchema>;
|
|
1332
|
+
validate?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
|
|
1333
|
+
setup?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
|
|
1334
|
+
ready?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
|
|
1335
|
+
dispose?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
|
|
1336
|
+
log?: FarmIntegrationLogger;
|
|
1337
|
+
routes?: readonly FarmIntegrationRoute<any, any, TSchema>[];
|
|
1338
|
+
endpoints?: FarmIntegrationEndpoints<TSchema>;
|
|
1339
|
+
middleware?: readonly FarmIntegrationMiddleware<TSchema>[];
|
|
1340
|
+
providers?: readonly FarmIntegrationProvider[];
|
|
1341
|
+
documentNavigations?: readonly FarmIntegrationDocumentNavigation[];
|
|
1342
|
+
plugins?: readonly FarmPlugin[];
|
|
1343
|
+
}
|
|
1344
|
+
type FarmIntegrationsUserConfig = Record<string, FarmIntegration<any, any> | undefined>;
|
|
1345
|
+
/** @internal Identifies lifecycle plugins owned by platform-managed integrations. */
|
|
1346
|
+
declare function getFarmIntegrationPluginServerRuntime(plugin: FarmPlugin): boolean | undefined;
|
|
1347
|
+
type IntegrationRouteBuilderOptions<TBody, TQuery, TServer extends boolean, TSchema extends FarmIntegrationSchema | undefined> = {
|
|
1348
|
+
middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
|
|
1349
|
+
before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
|
|
1350
|
+
after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
|
|
1351
|
+
rawBody?: boolean;
|
|
1352
|
+
headers?: Record<string, string>;
|
|
1353
|
+
credentials?: RequestCredentials;
|
|
1354
|
+
bodyFormat?: FarmIntegrationAPIBodyFormat;
|
|
1355
|
+
responseFormat?: FarmIntegrationAPIResponseFormat;
|
|
1356
|
+
isServer?: TServer;
|
|
1357
|
+
body?: FarmIntegrationInputSchema<TBody>;
|
|
1358
|
+
query?: FarmIntegrationInputSchema<TQuery>;
|
|
1359
|
+
input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
|
|
1360
|
+
handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
|
|
1361
|
+
};
|
|
1362
|
+
interface FarmIntegrationRouteFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
|
|
1363
|
+
get<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "GET", TSchema>;
|
|
1364
|
+
post<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "POST", TSchema>;
|
|
1365
|
+
put<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "PUT", TSchema>;
|
|
1366
|
+
patch<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "PATCH", TSchema>;
|
|
1367
|
+
delete<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "DELETE", TSchema>;
|
|
1368
|
+
options<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "OPTIONS", TSchema>;
|
|
1369
|
+
head<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "HEAD", TSchema>;
|
|
1370
|
+
}
|
|
1371
|
+
interface FarmIntegrationRoutesFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
|
|
1372
|
+
route: FarmIntegrationRouteFactory<TSchema>;
|
|
1373
|
+
integrationRoute: FarmIntegrationRouteFactory<TSchema>;
|
|
1374
|
+
}
|
|
1375
|
+
type FarmIntegrationRoutesFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationRoutesFactoryContext<TSchema>) => readonly FarmIntegrationRoute<any, any, TSchema>[];
|
|
1376
|
+
type FarmIntegrationEndpointValue<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationRoute<any, any, TSchema> | readonly FarmIntegrationEndpointValue<TSchema>[] | {
|
|
1377
|
+
readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
|
|
1378
|
+
};
|
|
1379
|
+
type FarmIntegrationEndpoints<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
|
|
1380
|
+
readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
|
|
1381
|
+
};
|
|
1382
|
+
interface FarmIntegrationEndpointsFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationRoutesFactoryContext<TSchema> {
|
|
1383
|
+
endpoint: FarmIntegrationRouteFactory<TSchema>;
|
|
1384
|
+
}
|
|
1385
|
+
type FarmIntegrationEndpointsFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationEndpointsFactoryContext<TSchema>) => FarmIntegrationEndpoints<TSchema>;
|
|
1386
|
+
declare function createIntegrationRoute<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined>(_schema?: TSchema): FarmIntegrationRouteFactory<TSchema>;
|
|
1387
|
+
declare const integrationRoute: FarmIntegrationRouteFactory<undefined>;
|
|
1388
|
+
type RegisteredIntegrationRuntime = {
|
|
1389
|
+
integration: FarmIntegration;
|
|
1390
|
+
config: FarmPluginContext["config"];
|
|
1391
|
+
isDev: boolean;
|
|
1392
|
+
isProd: boolean;
|
|
1393
|
+
};
|
|
1394
|
+
type FarmIntegrationRoutesInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = readonly FarmIntegrationRoute<any, any, TSchema>[] | FarmIntegrationRoutesFactory<TSchema>;
|
|
1395
|
+
type FarmIntegrationEndpointsInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationEndpoints<TSchema> | FarmIntegrationEndpointsFactory<TSchema>;
|
|
1396
|
+
type FarmIntegrationInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined, TConfig = unknown> = Omit<FarmIntegration<TSchema, TConfig>, "kind" | "category" | "slot" | "config" | "routes" | "endpoints"> & {
|
|
1397
|
+
config?: FarmIntegrationConfigInput<TConfig, TSchema>;
|
|
1398
|
+
routes?: FarmIntegrationRoutesInput<TSchema>;
|
|
1399
|
+
endpoints?: FarmIntegrationEndpointsInput<TSchema>;
|
|
1400
|
+
} & ({
|
|
1401
|
+
category: FarmIntegrationCategory;
|
|
1402
|
+
slot?: FarmIntegrationCategory;
|
|
1403
|
+
} | {
|
|
1404
|
+
category?: FarmIntegrationCategory;
|
|
1405
|
+
slot: FarmIntegrationCategory;
|
|
1406
|
+
});
|
|
1407
|
+
type FarmIntegrationCategoryInput = {
|
|
1408
|
+
category: FarmIntegrationCategory;
|
|
1409
|
+
slot?: FarmIntegrationCategory;
|
|
1410
|
+
} | {
|
|
1411
|
+
category?: FarmIntegrationCategory;
|
|
1412
|
+
slot: FarmIntegrationCategory;
|
|
1413
|
+
};
|
|
1414
|
+
type FarmIntegrationShapeForInference = FarmIntegrationCategoryInput & {
|
|
1415
|
+
api?: FarmIntegrationAPI;
|
|
1416
|
+
schema?: FarmIntegrationSchema;
|
|
1417
|
+
config?: unknown;
|
|
1418
|
+
routes?: unknown;
|
|
1419
|
+
endpoints?: unknown;
|
|
1420
|
+
};
|
|
1421
|
+
type ExtractIntegrationSchema<TIntegration> = TIntegration extends {
|
|
1422
|
+
schema: infer TSchema extends FarmIntegrationSchema;
|
|
1423
|
+
} ? TSchema : undefined;
|
|
1424
|
+
type ResolveIntegrationRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = TRoutes extends FarmIntegrationRoutesFactory<TSchema> ? ReturnType<TRoutes> : TRoutes;
|
|
1425
|
+
type ResolveIntegrationEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = TEndpoints extends FarmIntegrationEndpointsFactory<TSchema> ? ReturnType<TEndpoints> : TEndpoints;
|
|
1426
|
+
type ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = ResolveIntegrationRoutesInput<TRoutes, TSchema> extends readonly (infer TRoute)[] ? TRoute : never;
|
|
1427
|
+
type ExtractIntegrationRoutesFromEndpointValue<TValue> = TValue extends FarmIntegrationRouteOperationCarrier<string, any> ? TValue : TValue extends readonly (infer TItem)[] ? ExtractIntegrationRoutesFromEndpointValue<TItem> : TValue extends object ? ExtractIntegrationRoutesFromEndpointValue<TValue[keyof TValue]> : never;
|
|
1428
|
+
type ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = ExtractIntegrationRoutesFromEndpointValue<ResolveIntegrationEndpointsInput<TEndpoints, TSchema>>;
|
|
1429
|
+
type ExtractIntegrationRouteUnion<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = (TIntegration extends {
|
|
1430
|
+
routes: infer TRoutes;
|
|
1431
|
+
} ? ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema> : never) | (TIntegration extends {
|
|
1432
|
+
endpoints: infer TEndpoints;
|
|
1433
|
+
} ? ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema> : never);
|
|
1434
|
+
type ExtractDefinedIntegrationRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = [ExtractIntegrationRouteUnion<TIntegration, TSchema>] extends [never] ? undefined : readonly ExtractIntegrationRouteUnion<TIntegration, TSchema>[];
|
|
1435
|
+
type ExtractDefinedIntegrationEndpoints<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = TIntegration extends {
|
|
1436
|
+
endpoints: infer TEndpoints;
|
|
1437
|
+
} ? ResolveIntegrationEndpointsInput<TEndpoints, TSchema> : undefined;
|
|
1438
|
+
type ExtractIntegrationAPIRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = Extract<ExtractIntegrationRouteUnion<TIntegration, TSchema>, FarmIntegrationRouteOperationCarrier<string, any>>;
|
|
1439
|
+
type ExtractIntegrationCategory<TIntegration extends FarmIntegrationCategoryInput> = TIntegration extends {
|
|
1440
|
+
category: infer TCategory extends FarmIntegrationCategory;
|
|
1441
|
+
} ? TCategory : TIntegration extends {
|
|
1442
|
+
slot: infer TSlot extends FarmIntegrationCategory;
|
|
1443
|
+
} ? TSlot : FarmIntegrationCategory;
|
|
1444
|
+
type ExtractDerivedIntegrationAPI<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = TIntegration extends {
|
|
1445
|
+
api: infer TAPI extends FarmIntegrationAPI;
|
|
1446
|
+
} ? TAPI : [ExtractIntegrationAPIRoutes<TIntegration, TSchema>] extends [never] ? FarmIntegrationAPI | undefined : InferIntegrationAPIFromRoutes<readonly ExtractIntegrationAPIRoutes<TIntegration, TSchema>[]>;
|
|
1447
|
+
type DefinedIntegration<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = Omit<TIntegration, "kind" | "category" | "slot" | "api" | "routes" | "endpoints"> & {
|
|
1448
|
+
readonly kind: "farm-integration";
|
|
1449
|
+
category: ExtractIntegrationCategory<TIntegration>;
|
|
1450
|
+
slot: ExtractIntegrationCategory<TIntegration>;
|
|
1451
|
+
routes: ExtractDefinedIntegrationRoutes<TIntegration, TSchema>;
|
|
1452
|
+
endpoints: ExtractDefinedIntegrationEndpoints<TIntegration, TSchema>;
|
|
1453
|
+
api: ExtractDerivedIntegrationAPI<TIntegration, TSchema>;
|
|
1454
|
+
};
|
|
1455
|
+
declare function defineIntegration<const TSchema extends FarmIntegrationSchema | undefined, const TConfig, TIntegration extends FarmIntegrationInput<TSchema, TConfig>>(integration: TIntegration & FarmIntegrationInput<TSchema, TConfig>): DefinedIntegration<TIntegration, TSchema>;
|
|
1456
|
+
declare function isFarmIntegration(value: unknown): value is FarmIntegration;
|
|
1457
|
+
declare function resolveIntegrationPlugins(integrations: FarmIntegrationsUserConfig | undefined): FarmPlugin[];
|
|
1458
|
+
declare function getIntegrationProviders(integrations: FarmIntegrationsUserConfig | undefined): Array<Pick<FarmIntegrationProvider, "name" | "type" | "props">>;
|
|
1459
|
+
declare function getIntegrationDocumentNavigationMatchers(integrations: FarmIntegrationsUserConfig | undefined): string[];
|
|
1460
|
+
declare function getIntegrationSchemas(integrations: FarmIntegrationsUserConfig | undefined): Record<string, FarmIntegrationSchema>;
|
|
1461
|
+
declare function getRegisteredIntegrationRuntime(key: string): RegisteredIntegrationRuntime | undefined;
|
|
1462
|
+
declare function getRegisteredIntegrations(): Record<string, FarmIntegration>;
|
|
1463
|
+
declare function getRegisteredIntegrationSchemas(): Record<string, FarmIntegrationSchema>;
|
|
1464
|
+
declare function matchIntegrationRoute(integrations: FarmIntegrationsUserConfig | undefined, input: {
|
|
1465
|
+
pathname: string;
|
|
1466
|
+
method?: string;
|
|
1467
|
+
}): {
|
|
1468
|
+
key: string;
|
|
1469
|
+
integration: FarmIntegration;
|
|
1470
|
+
route: {
|
|
1471
|
+
path: string;
|
|
1472
|
+
methods: readonly string[];
|
|
1473
|
+
};
|
|
1474
|
+
params: FarmIntegrationRouteParams;
|
|
1475
|
+
} | null;
|
|
1476
|
+
declare function matchRegisteredIntegrationRoute(input: {
|
|
1477
|
+
pathname: string;
|
|
1478
|
+
method?: string;
|
|
1479
|
+
}): {
|
|
1480
|
+
key: string;
|
|
1481
|
+
integration: FarmIntegration;
|
|
1482
|
+
route: {
|
|
1483
|
+
path: string;
|
|
1484
|
+
methods: readonly string[];
|
|
1485
|
+
};
|
|
1486
|
+
params: FarmIntegrationRouteParams;
|
|
1487
|
+
} | null;
|
|
1488
|
+
declare function getRegisteredIntegrationAPIManifest(): Record<string, FarmIntegrationAPI>;
|
|
1489
|
+
declare function dispatchIntegrationRequest(runtime: RegisteredIntegrationRuntime, request: Request, options?: {
|
|
1490
|
+
currentRequest?: Request;
|
|
1491
|
+
data?: FarmIntegrationData;
|
|
1492
|
+
internal?: boolean;
|
|
1493
|
+
}): Promise<Response | null>;
|
|
1494
|
+
|
|
1495
|
+
declare global {
|
|
1496
|
+
namespace FarmJS {
|
|
1497
|
+
/** @internal Application route patterns registered by generated types. */
|
|
1498
|
+
interface RouteRegistry {
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
/** All generated route module patterns for the current application. */
|
|
1503
|
+
type AppRoutePattern = FarmJS.RouteRegistry extends {
|
|
1504
|
+
pattern: infer TPattern extends string;
|
|
1505
|
+
} ? TPattern : string;
|
|
1506
|
+
type FarmRoutePropsDefault = never;
|
|
1507
|
+
type FarmRoutePropsTarget = AppRoutePattern;
|
|
1508
|
+
type StripPageRouteSuffix<TRoute extends string> = TRoute extends `${infer TPath}?${string}` ? StripPageRouteSuffix<TPath> : TRoute extends `${infer TPath}#${string}` ? StripPageRouteSuffix<TPath> : TRoute;
|
|
1509
|
+
type SimplifyPageRouteParams<TValue> = {
|
|
1510
|
+
[TKey in keyof TValue]: TValue[TKey];
|
|
1511
|
+
} & {};
|
|
1512
|
+
type PageRouteSegmentParams<TSegment extends string> = TSegment extends `[[...${infer TParam}]]` ? {
|
|
1513
|
+
[TKey in TParam]?: string;
|
|
1514
|
+
} : TSegment extends `[...${infer TParam}]` ? {
|
|
1515
|
+
[TKey in TParam]: string;
|
|
1516
|
+
} : TSegment extends `[${infer TParam}]` ? {
|
|
1517
|
+
[TKey in TParam]: string;
|
|
1518
|
+
} : {};
|
|
1519
|
+
type ExtractPageRouteParams<TRoute extends string> = TRoute extends `${infer TSegment}/${infer TRest}` ? PageRouteSegmentParams<TSegment> & ExtractPageRouteParams<TRest> : PageRouteSegmentParams<TRoute>;
|
|
1520
|
+
/** Infer the decoded params received by a page from a route pattern. */
|
|
1521
|
+
type PageRouteParams<TRoute extends string> = string extends TRoute ? Record<string, string> : TRoute extends string ? SimplifyPageRouteParams<ExtractPageRouteParams<StripPageRouteSuffix<TRoute>>> : never;
|
|
1522
|
+
type ResolvePageRouteParams<TRoute extends FarmRoutePropsTarget> = [TRoute] extends [never] ? Record<string, string> : TRoute extends string ? PageRouteParams<TRoute> : Record<string, string>;
|
|
1523
|
+
type NitroPreset = "node-server" | "vercel" | "cloudflare" | "cloudflare-pages" | "netlify" | "netlify-edge" | "bun" | "deno" | "azure" | "aws-lambda" | "firebase" | "custom" | "self-host" | "farm" | string;
|
|
1524
|
+
type FarmMigrationCommand = string | {
|
|
1525
|
+
/** Shell command to run for this migration step. */
|
|
1526
|
+
command: string;
|
|
1527
|
+
/** Optional label printed by the CLI before running the command. */
|
|
1528
|
+
name?: string;
|
|
1529
|
+
/** Working directory for this command, relative to the project root unless absolute. */
|
|
1530
|
+
cwd?: string;
|
|
1531
|
+
/** Additional environment variables for this command. */
|
|
1532
|
+
env?: Record<string, string | undefined>;
|
|
1533
|
+
/** Skip this command without removing it from config. */
|
|
1534
|
+
skip?: boolean;
|
|
1535
|
+
};
|
|
1536
|
+
interface FarmMigrationsConfig {
|
|
1537
|
+
/** One-shot commands that create or update app/integration schemas. */
|
|
1538
|
+
commands?: FarmMigrationCommand[];
|
|
1539
|
+
}
|
|
1540
|
+
type FarmMigrationsUserConfig = FarmMigrationsConfig | FarmMigrationCommand[];
|
|
1541
|
+
interface ResolvedFarmMigrationsConfig {
|
|
1542
|
+
commands: FarmMigrationCommand[];
|
|
1543
|
+
}
|
|
1544
|
+
interface FarmContextFactoryInput {
|
|
1545
|
+
request: Request;
|
|
1546
|
+
rawRequest?: FarmRequest;
|
|
1547
|
+
params: Record<string, string>;
|
|
1548
|
+
search: Record<string, string | string[] | undefined>;
|
|
1549
|
+
path: string;
|
|
1550
|
+
}
|
|
1551
|
+
type FarmContextFactory<TContext = unknown> = (input: FarmContextFactoryInput) => TContext | Promise<TContext>;
|
|
1552
|
+
interface FarmAppContext {
|
|
1553
|
+
}
|
|
1554
|
+
interface FarmConfig {
|
|
1555
|
+
root?: string;
|
|
1556
|
+
/** App source directory. @default "src" */
|
|
1557
|
+
srcDir?: string;
|
|
1558
|
+
extends?: readonly FarmLayerEntry[];
|
|
1559
|
+
/** Resolved layer graph. Populated by config resolution. */
|
|
1560
|
+
layers?: readonly ResolvedFarmLayer[];
|
|
1561
|
+
outDir?: string;
|
|
1562
|
+
basePath?: string;
|
|
1563
|
+
preset?: NitroPreset;
|
|
1564
|
+
deploy?: {
|
|
1565
|
+
target?: "vercel" | "cloudflare" | "netlify" | "node" | string;
|
|
1566
|
+
preset?: NitroPreset;
|
|
1567
|
+
outputDir?: string;
|
|
1568
|
+
output?: string;
|
|
1569
|
+
projectName?: string;
|
|
1570
|
+
vercel?: {
|
|
1571
|
+
outputDirectory?: string;
|
|
1572
|
+
buildCommand?: string;
|
|
1573
|
+
installCommand?: string;
|
|
1574
|
+
framework?: string | null;
|
|
1575
|
+
};
|
|
1576
|
+
cloudflare?: {
|
|
1577
|
+
outputDir?: string;
|
|
1578
|
+
projectName?: string;
|
|
1579
|
+
};
|
|
1580
|
+
netlify?: {
|
|
1581
|
+
outputDir?: string;
|
|
1582
|
+
site?: string;
|
|
1583
|
+
};
|
|
1584
|
+
};
|
|
1585
|
+
storage?: FarmStorageUserConfig;
|
|
1586
|
+
/** Shared application data, route, ISR, and PPR cache. */
|
|
1587
|
+
cache?: FarmCacheUserConfig;
|
|
1588
|
+
integrations?: FarmIntegrationsUserConfig;
|
|
1589
|
+
/** Farm-native authentication. `true` enables email/password auth. */
|
|
1590
|
+
auth?: FarmAuthUserConfig | ResolvedFarmAuthConfig;
|
|
1591
|
+
plugins?: FarmPlugin[];
|
|
1592
|
+
migrations?: FarmMigrationsUserConfig;
|
|
1593
|
+
/** Map portable cron schedules to ordinary GET API routes. */
|
|
1594
|
+
cron?: FarmCronUserConfig | FarmCronResolvedConfig | false;
|
|
1595
|
+
workflows?: FarmWorkflowsUserConfig | boolean;
|
|
1596
|
+
env?: FarmEnvConfig<any, any> | ResolvedFarmEnv;
|
|
1597
|
+
middleware?: FarmMiddlewareConfig;
|
|
1598
|
+
routeRules?: FarmRouteRules;
|
|
1599
|
+
context?: FarmContextFactory<any>;
|
|
1600
|
+
serverActions?: FarmServerActionsConfig;
|
|
1601
|
+
/** App-wide HTTP security policy. */
|
|
1602
|
+
security?: FarmSecurityConfig | ResolvedFarmSecurityConfig;
|
|
1603
|
+
images?: FarmImageConfig;
|
|
1604
|
+
/** Browser resource scheduling and preload budgets. */
|
|
1605
|
+
performance?: FarmPerformanceConfig;
|
|
1606
|
+
i18n?: FarmI18nUserConfig | ResolvedFarmI18nConfig | false;
|
|
1607
|
+
/** Build identifier used to detect stale clients during rolling deployments. */
|
|
1608
|
+
deploymentId?: string;
|
|
1609
|
+
docs?: FarmDocsUserConfig | FarmDocsResolvedConfig;
|
|
1610
|
+
md?: FarmMarkdownUserConfig | FarmMarkdownResolvedConfig | boolean;
|
|
1611
|
+
mdx?: FarmMdxUserConfig | FarmMdxResolvedConfig;
|
|
1612
|
+
observability?: FarmObservabilityUserConfig;
|
|
1613
|
+
/** Development-only runtime inspector. Enabled by default during `farm dev`. */
|
|
1614
|
+
devtools?: FarmDevtoolsUserConfig;
|
|
1615
|
+
/**
|
|
1616
|
+
* When true, Link href is not strictly typed (accepts any string).
|
|
1617
|
+
* Use when you want to skip route-type errors on Link or don't use generated route types.
|
|
1618
|
+
*/
|
|
1619
|
+
suppressLintOnLink?: boolean;
|
|
1620
|
+
experimental?: {
|
|
1621
|
+
serverComponents?: boolean;
|
|
1622
|
+
serverActions?: boolean;
|
|
1623
|
+
/**
|
|
1624
|
+
* Automatically optimize eligible server-only host-element subtrees with
|
|
1625
|
+
* the native Strata renderer. Unsupported trees keep normal React
|
|
1626
|
+
* rendering; no application boundary component is required.
|
|
1627
|
+
*
|
|
1628
|
+
* @experimental
|
|
1629
|
+
* @default false
|
|
1630
|
+
*/
|
|
1631
|
+
optimizedBoundary?: boolean;
|
|
1632
|
+
};
|
|
1633
|
+
vite?: any;
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Middleware data available in page components
|
|
1637
|
+
*/
|
|
1638
|
+
interface MiddlewareProps {
|
|
1639
|
+
/**
|
|
1640
|
+
* Map containing all data set by middleware via ctx.data.set()
|
|
1641
|
+
*
|
|
1642
|
+
* @example
|
|
1643
|
+
* ```tsx
|
|
1644
|
+
* // In middleware.ts
|
|
1645
|
+
* ctx.data.set('user', { id: 1, name: 'John' });
|
|
1646
|
+
*
|
|
1647
|
+
* // In page.tsx
|
|
1648
|
+
* const user = props.middleware?.data.get('user');
|
|
1649
|
+
* ```
|
|
1650
|
+
*/
|
|
1651
|
+
data: Map<string, any>;
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Plugin context data available in server page components.
|
|
1655
|
+
* Only values explicitly exposed by plugins are included.
|
|
1656
|
+
*/
|
|
1657
|
+
interface PluginContextProps {
|
|
1658
|
+
data: Map<string, any>;
|
|
1659
|
+
}
|
|
1660
|
+
/**
|
|
1661
|
+
* Page component props
|
|
1662
|
+
*
|
|
1663
|
+
* @param params - Dynamic route parameters (e.g., { id: '123' } for /users/[id])
|
|
1664
|
+
* @param searchParams - URL search/query parameters
|
|
1665
|
+
* @param path - Current pathname
|
|
1666
|
+
* @param middleware - Data set by middleware.ts (optional, available if middleware exists)
|
|
1667
|
+
* @param context - Data explicitly exposed by plugins for this request (optional)
|
|
1668
|
+
*/
|
|
1669
|
+
interface PageProps<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> {
|
|
1670
|
+
params: ResolvePageRouteParams<TRoute>;
|
|
1671
|
+
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
|
1672
|
+
path: string;
|
|
1673
|
+
/**
|
|
1674
|
+
* Data from middleware.ts in the same directory or parent directories
|
|
1675
|
+
* Access data via props.middleware?.data.get('key')
|
|
1676
|
+
*
|
|
1677
|
+
* @example
|
|
1678
|
+
* ```tsx
|
|
1679
|
+
* export default function Page(props: PageProps) {
|
|
1680
|
+
* const user = props.middleware?.data.get('user');
|
|
1681
|
+
* const stats = props.middleware?.data.get('dashboardStats');
|
|
1682
|
+
*
|
|
1683
|
+
* return <div>Welcome {user?.name}</div>;
|
|
1684
|
+
* }
|
|
1685
|
+
* ```
|
|
1686
|
+
*/
|
|
1687
|
+
middleware?: MiddlewareProps;
|
|
1688
|
+
/**
|
|
1689
|
+
* Request-scoped plugin context values explicitly exposed by plugins.
|
|
1690
|
+
* Access data via props.context?.data.get('key').
|
|
1691
|
+
*/
|
|
1692
|
+
context?: PluginContextProps;
|
|
1693
|
+
}
|
|
1694
|
+
interface LoadingProps<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> {
|
|
1695
|
+
params: ResolvePageRouteParams<TRoute>;
|
|
1696
|
+
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
|
1697
|
+
search?: Record<string, string | string[] | undefined>;
|
|
1698
|
+
path: string;
|
|
1699
|
+
middleware?: MiddlewareProps;
|
|
1700
|
+
context?: PluginContextProps;
|
|
1701
|
+
}
|
|
1702
|
+
interface ErrorProps<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> extends LoadingProps<TRoute> {
|
|
1703
|
+
error: unknown;
|
|
1704
|
+
reset: () => void;
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Helper type to create typed page props with specific middleware data shape
|
|
1708
|
+
*
|
|
1709
|
+
* @example
|
|
1710
|
+
* ```tsx
|
|
1711
|
+
* interface MyMiddlewareData {
|
|
1712
|
+
* user: { id: number; name: string };
|
|
1713
|
+
* stats: { views: number };
|
|
1714
|
+
* }
|
|
1715
|
+
*
|
|
1716
|
+
* type MyPageProps = PagePropsWithMiddleware<MyMiddlewareData>;
|
|
1717
|
+
*
|
|
1718
|
+
* export default function Page(props: MyPageProps) {
|
|
1719
|
+
* const user = props.middleware?.data.get('user'); // Fully typed!
|
|
1720
|
+
* const stats = props.middleware?.data.get('stats'); // Fully typed!
|
|
1721
|
+
*
|
|
1722
|
+
* return <div>Welcome {user?.name}</div>;
|
|
1723
|
+
* }
|
|
1724
|
+
* ```
|
|
1725
|
+
*/
|
|
1726
|
+
type PagePropsWithMiddleware<T extends Record<string, any>, TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> = PageProps<TRoute> & {
|
|
1727
|
+
middleware: {
|
|
1728
|
+
data: Map<keyof T, T[keyof T]>;
|
|
1729
|
+
};
|
|
1730
|
+
};
|
|
1731
|
+
interface LayoutProps<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> {
|
|
1732
|
+
children: ReactNode;
|
|
1733
|
+
params: ResolvePageRouteParams<TRoute>;
|
|
1734
|
+
}
|
|
1735
|
+
/** Props passed to a route's `generateMetadata` function. */
|
|
1736
|
+
type MetadataProps<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> = PageProps<TRoute>;
|
|
1737
|
+
/** Props passed to a layout's `generateMetadata` function. */
|
|
1738
|
+
interface LayoutMetadataProps<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> {
|
|
1739
|
+
params: ResolvePageRouteParams<TRoute>;
|
|
1740
|
+
}
|
|
1741
|
+
type Page<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> = ComponentType<PageProps<TRoute>>;
|
|
1742
|
+
type Layout<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> = ComponentType<LayoutProps<TRoute>>;
|
|
1743
|
+
type Loading<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> = ComponentType<LoadingProps<TRoute>>;
|
|
1744
|
+
type ErrorBoundary<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> = ComponentType<ErrorProps<TRoute>>;
|
|
1745
|
+
/**
|
|
1746
|
+
* Route module exports for pages
|
|
1747
|
+
*
|
|
1748
|
+
* SSR is the default - pages render on each request
|
|
1749
|
+
* SSG is opt-in via `export const ssg = true`, Next-compatible route
|
|
1750
|
+
* config exports, or a top-of-file rendering directive.
|
|
1751
|
+
*
|
|
1752
|
+
* @example SSR Page (default):
|
|
1753
|
+
* ```tsx
|
|
1754
|
+
* export default async function Page() {
|
|
1755
|
+
* const data = await fetchData();
|
|
1756
|
+
* return <div>{data.title}</div>;
|
|
1757
|
+
* }
|
|
1758
|
+
* ```
|
|
1759
|
+
*
|
|
1760
|
+
* @example SSG Page:
|
|
1761
|
+
* ```tsx
|
|
1762
|
+
* export const ssg = true;
|
|
1763
|
+
*
|
|
1764
|
+
* export default function AboutPage() {
|
|
1765
|
+
* return <h1>About Us</h1>;
|
|
1766
|
+
* }
|
|
1767
|
+
* ```
|
|
1768
|
+
*
|
|
1769
|
+
* @example SSG with Revalidation (ISR):
|
|
1770
|
+
* ```tsx
|
|
1771
|
+
* export const ssg = true;
|
|
1772
|
+
* export const revalidate = 60; // Regenerate every 60 seconds
|
|
1773
|
+
*
|
|
1774
|
+
* export default async function ProductsPage() {
|
|
1775
|
+
* const products = await fetchProducts();
|
|
1776
|
+
* return <ProductList products={products} />;
|
|
1777
|
+
* }
|
|
1778
|
+
* ```
|
|
1779
|
+
*
|
|
1780
|
+
* @example Dynamic SSG Route:
|
|
1781
|
+
* ```tsx
|
|
1782
|
+
* export const ssg = true;
|
|
1783
|
+
*
|
|
1784
|
+
* export async function getStaticPaths() {
|
|
1785
|
+
* const posts = await fetchPosts();
|
|
1786
|
+
* return posts.map(post => ({ slug: post.slug }));
|
|
1787
|
+
* }
|
|
1788
|
+
*
|
|
1789
|
+
* export default async function BlogPost({ params }) {
|
|
1790
|
+
* const post = await fetchPost(params.slug);
|
|
1791
|
+
* return <article>{post.title}</article>;
|
|
1792
|
+
* }
|
|
1793
|
+
* ```
|
|
1794
|
+
*
|
|
1795
|
+
* @example Next-compatible Route Config:
|
|
1796
|
+
* ```tsx
|
|
1797
|
+
* export const dynamic = "force-static";
|
|
1798
|
+
* export const revalidate = 60;
|
|
1799
|
+
*
|
|
1800
|
+
* export default function DocsPage() {
|
|
1801
|
+
* return <h1>Docs</h1>;
|
|
1802
|
+
* }
|
|
1803
|
+
* ```
|
|
1804
|
+
*
|
|
1805
|
+
* @example Directive Route Config:
|
|
1806
|
+
* ```tsx
|
|
1807
|
+
* "use ssg; 60";
|
|
1808
|
+
*
|
|
1809
|
+
* export default function DocsPage() {
|
|
1810
|
+
* return <h1>Docs</h1>;
|
|
1811
|
+
* }
|
|
1812
|
+
* ```
|
|
1813
|
+
*/
|
|
1814
|
+
interface RouteModule<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> {
|
|
1815
|
+
default?: Page<TRoute>;
|
|
1816
|
+
/** Execution runtime for this route. Layout values are inherited unless overridden. */
|
|
1817
|
+
runtime?: FarmRouteRuntime;
|
|
1818
|
+
/** Provider-specific execution regions, or "auto" to clear an inherited value. */
|
|
1819
|
+
regions?: FarmRouteRegions;
|
|
1820
|
+
/** Maximum execution time in seconds, or "auto" to use the provider default. */
|
|
1821
|
+
maxDuration?: FarmRouteMaxDuration;
|
|
1822
|
+
/**
|
|
1823
|
+
* Mark this page for Static Site Generation (SSG)
|
|
1824
|
+
* When true, the page will be pre-rendered at build time
|
|
1825
|
+
*/
|
|
1826
|
+
ssg?: boolean;
|
|
1827
|
+
/**
|
|
1828
|
+
* Revalidate interval in seconds for Incremental Static Regeneration (ISR)
|
|
1829
|
+
* Only applicable when ssg = true
|
|
1830
|
+
*/
|
|
1831
|
+
revalidate?: number | false;
|
|
1832
|
+
/**
|
|
1833
|
+
* Next.js-compatible rendering mode.
|
|
1834
|
+
* - force-static/error: pre-render at build time
|
|
1835
|
+
* - force-dynamic: render on each request
|
|
1836
|
+
*/
|
|
1837
|
+
dynamic?: "auto" | "force-static" | "force-dynamic" | "error";
|
|
1838
|
+
/**
|
|
1839
|
+
* Opt into Partial Prerendering/static-shell caching for this route.
|
|
1840
|
+
* Compatible with Farm's `ppr` export and Next.js `experimental_ppr`.
|
|
1841
|
+
*/
|
|
1842
|
+
ppr?: boolean;
|
|
1843
|
+
experimental_ppr?: boolean;
|
|
1844
|
+
/**
|
|
1845
|
+
* Return all paths to pre-render for dynamic SSG routes
|
|
1846
|
+
* Required for dynamic routes (e.g., [slug]) when ssg = true
|
|
1847
|
+
*/
|
|
1848
|
+
getStaticPaths?: GenerateStaticParams<TRoute>;
|
|
1849
|
+
/**
|
|
1850
|
+
* @deprecated Use getStaticPaths instead
|
|
1851
|
+
*/
|
|
1852
|
+
generateStaticParams?: GenerateStaticParams<TRoute>;
|
|
1853
|
+
metadata?: Metadata & Record<string, any>;
|
|
1854
|
+
generateMetadata?: (props: MetadataProps<TRoute>) => Promise<Metadata> | Metadata;
|
|
1855
|
+
}
|
|
1856
|
+
/** A value accepted for one static route parameter. */
|
|
1857
|
+
type StaticPathPrimitive = string | number | boolean;
|
|
1858
|
+
/**
|
|
1859
|
+
* Parameters returned by `getStaticPaths` or `generateStaticParams`.
|
|
1860
|
+
* Arrays create individual URL segments for catch-all route parameters.
|
|
1861
|
+
*/
|
|
1862
|
+
type StaticPathParams = Record<string, StaticPathPrimitive | readonly StaticPathPrimitive[]>;
|
|
1863
|
+
type StaticRouteSegmentParams<TSegment extends string> = TSegment extends `[[...${infer TParam}]]` ? {
|
|
1864
|
+
[TKey in TParam]?: readonly StaticPathPrimitive[];
|
|
1865
|
+
} : TSegment extends `[...${infer TParam}]` ? {
|
|
1866
|
+
[TKey in TParam]: readonly StaticPathPrimitive[];
|
|
1867
|
+
} : TSegment extends `[${infer TParam}]` ? {
|
|
1868
|
+
[TKey in TParam]: StaticPathPrimitive;
|
|
1869
|
+
} : {};
|
|
1870
|
+
type ExtractStaticRouteParams<TRoute extends string> = TRoute extends `${infer TSegment}/${infer TRest}` ? StaticRouteSegmentParams<TSegment> & ExtractStaticRouteParams<TRest> : StaticRouteSegmentParams<TRoute>;
|
|
1871
|
+
/** Infer the values accepted from `getStaticPaths` for a route pattern. */
|
|
1872
|
+
type StaticRouteParams<TRoute extends string> = string extends TRoute ? StaticPathParams : TRoute extends string ? SimplifyPageRouteParams<ExtractStaticRouteParams<StripPageRouteSuffix<TRoute>>> : never;
|
|
1873
|
+
type ResolveStaticRouteParams<TRoute extends FarmRoutePropsTarget> = [TRoute] extends [never] ? StaticPathParams : TRoute extends string ? StaticRouteParams<TRoute> : StaticPathParams;
|
|
1874
|
+
/** A route-aware `getStaticPaths` or `generateStaticParams` function. */
|
|
1875
|
+
type GenerateStaticParams<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> = () => Array<ResolveStaticRouteParams<TRoute>> | Promise<Array<ResolveStaticRouteParams<TRoute>>>;
|
|
1876
|
+
interface LayoutModule<TRoute extends FarmRoutePropsTarget = FarmRoutePropsDefault> {
|
|
1877
|
+
default: Layout<TRoute>;
|
|
1878
|
+
/** Semantic fonts inherited by framework-owned surfaces for this route. */
|
|
1879
|
+
fonts?: FarmLayoutFonts;
|
|
1880
|
+
runtime?: FarmRouteRuntime;
|
|
1881
|
+
regions?: FarmRouteRegions;
|
|
1882
|
+
maxDuration?: FarmRouteMaxDuration;
|
|
1883
|
+
metadata?: Metadata & Record<string, any>;
|
|
1884
|
+
generateMetadata?: (props: LayoutMetadataProps<TRoute>) => Promise<Metadata> | Metadata;
|
|
1885
|
+
}
|
|
1886
|
+
interface Metadata {
|
|
1887
|
+
metadataBase?: string | URL;
|
|
1888
|
+
title?: string | {
|
|
1889
|
+
default?: string;
|
|
1890
|
+
template?: string;
|
|
1891
|
+
};
|
|
1892
|
+
description?: string;
|
|
1893
|
+
keywords?: string | string[];
|
|
1894
|
+
author?: string;
|
|
1895
|
+
authors?: Array<{
|
|
1896
|
+
name: string;
|
|
1897
|
+
url?: string;
|
|
1898
|
+
}>;
|
|
1899
|
+
creator?: string;
|
|
1900
|
+
publisher?: string;
|
|
1901
|
+
robots?: string | {
|
|
1902
|
+
index?: boolean;
|
|
1903
|
+
follow?: boolean;
|
|
1904
|
+
};
|
|
1905
|
+
openGraph?: {
|
|
1906
|
+
title?: string;
|
|
1907
|
+
description?: string;
|
|
1908
|
+
url?: string;
|
|
1909
|
+
siteName?: string;
|
|
1910
|
+
images?: string | {
|
|
1911
|
+
url: string;
|
|
1912
|
+
width?: number;
|
|
1913
|
+
height?: number;
|
|
1914
|
+
alt?: string;
|
|
1915
|
+
type?: string;
|
|
1916
|
+
} | Array<{
|
|
1917
|
+
url: string;
|
|
1918
|
+
width?: number;
|
|
1919
|
+
height?: number;
|
|
1920
|
+
alt?: string;
|
|
1921
|
+
type?: string;
|
|
1922
|
+
}>;
|
|
1923
|
+
image?: string;
|
|
1924
|
+
type?: string;
|
|
1925
|
+
locale?: string;
|
|
1926
|
+
};
|
|
1927
|
+
twitter?: {
|
|
1928
|
+
card?: "summary" | "summary_large_image" | "app" | "player";
|
|
1929
|
+
site?: string;
|
|
1930
|
+
creator?: string;
|
|
1931
|
+
title?: string;
|
|
1932
|
+
description?: string;
|
|
1933
|
+
images?: string | {
|
|
1934
|
+
url: string;
|
|
1935
|
+
width?: number;
|
|
1936
|
+
height?: number;
|
|
1937
|
+
alt?: string;
|
|
1938
|
+
type?: string;
|
|
1939
|
+
} | Array<string | {
|
|
1940
|
+
url: string;
|
|
1941
|
+
width?: number;
|
|
1942
|
+
height?: number;
|
|
1943
|
+
alt?: string;
|
|
1944
|
+
type?: string;
|
|
1945
|
+
}>;
|
|
1946
|
+
};
|
|
1947
|
+
alternates?: {
|
|
1948
|
+
canonical?: string;
|
|
1949
|
+
languages?: Record<string, string>;
|
|
1950
|
+
};
|
|
1951
|
+
icons?: string | {
|
|
1952
|
+
icon?: string | Array<string | {
|
|
1953
|
+
url: string;
|
|
1954
|
+
sizes?: string;
|
|
1955
|
+
type?: string;
|
|
1956
|
+
}>;
|
|
1957
|
+
shortcut?: string | Array<string | {
|
|
1958
|
+
url: string;
|
|
1959
|
+
sizes?: string;
|
|
1960
|
+
type?: string;
|
|
1961
|
+
}>;
|
|
1962
|
+
apple?: string | Array<string | {
|
|
1963
|
+
url: string;
|
|
1964
|
+
sizes?: string;
|
|
1965
|
+
type?: string;
|
|
1966
|
+
}>;
|
|
1967
|
+
};
|
|
1968
|
+
manifest?: string;
|
|
1969
|
+
}
|
|
1970
|
+
interface FarmRequest extends IncomingMessage {
|
|
1971
|
+
params?: Record<string, string>;
|
|
1972
|
+
query?: Record<string, string | string[]>;
|
|
1973
|
+
body?: any;
|
|
1974
|
+
}
|
|
1975
|
+
interface FarmResponse extends ServerResponse {
|
|
1976
|
+
json: (data: any) => void;
|
|
1977
|
+
status: (code: number) => FarmResponse;
|
|
1978
|
+
redirect: (url: string, status?: number) => void;
|
|
1979
|
+
}
|
|
1980
|
+
type ServerAction = (...args: any[]) => Promise<any>;
|
|
1981
|
+
interface RouteSegment {
|
|
1982
|
+
segment: string;
|
|
1983
|
+
isDynamic: boolean;
|
|
1984
|
+
isOptional: boolean;
|
|
1985
|
+
isCatchAll: boolean;
|
|
1986
|
+
}
|
|
1987
|
+
interface ParsedRoute {
|
|
1988
|
+
segments: RouteSegment[];
|
|
1989
|
+
filePath: string;
|
|
1990
|
+
type: "page" | "layout" | "loading" | "error" | "not-found";
|
|
1991
|
+
}
|
|
1992
|
+
interface BuildOptions {
|
|
1993
|
+
mode: "development" | "production";
|
|
1994
|
+
ssr: boolean;
|
|
1995
|
+
minify: boolean;
|
|
1996
|
+
sourcemap: boolean;
|
|
1997
|
+
}
|
|
1998
|
+
/**
|
|
1999
|
+
* Represents a page to be pre-rendered at build time (SSG)
|
|
2000
|
+
*/
|
|
2001
|
+
interface SSGPage {
|
|
2002
|
+
/** The URL path for this page */
|
|
2003
|
+
urlPath: string;
|
|
2004
|
+
/** The file path to the page module */
|
|
2005
|
+
filePath: string;
|
|
2006
|
+
/** Route parameters for dynamic routes */
|
|
2007
|
+
params: Record<string, string>;
|
|
2008
|
+
/** Revalidation interval in seconds (ISR) */
|
|
2009
|
+
revalidate?: number;
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Result of SSG page collection
|
|
2013
|
+
*/
|
|
2014
|
+
interface SSGCollectionResult {
|
|
2015
|
+
/** Pages to pre-render at build time */
|
|
2016
|
+
ssg: SSGPage[];
|
|
2017
|
+
/** Routes that will be server-rendered on each request */
|
|
2018
|
+
ssr: string[];
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
export { type FarmPlugin as $, type AppRoutePattern as A, type RouteSegment as B, type ParsedRoute as C, type BuildOptions as D, type ErrorProps as E, type FarmConfig as F, type GenerateStaticParams as G, type SSGPage as H, type SSGCollectionResult as I, type FarmLayerEntry as J, type ResolvedFarmLayer as K, type LoadingProps as L, type MiddlewareProps as M, type NitroPreset as N, type FarmSourceRoot as O, type PageRouteParams as P, type ResolveFarmLayersOptions as Q, type ResolvedFarmMigrationsConfig as R, type StaticPathPrimitive as S, type FarmLayerResolution as T, resolveFarmLayers as U, getFarmSourceRoots as V, getFarmAppDirectories as W, getFarmLayerAliases as X, loadFarmConfigFile as Y, type FarmUserConfig as Z, type BundleResultPayload as _, type FarmMigrationCommand as a, type FarmPluginDevHooks as a$, type FarmIntegration as a0, type ReadonlyMiddlewareStore as a1, type FarmMiddlewareConfig as a2, type MiddlewareModule as a3, manageFarmDocumentPreloads as a4, manageFarmHtmlPreloads as a5, manageFarmLinkHeaderPreloads as a6, reportFarmPreloadWarnings as a7, type FarmMdxResolvedConfig as a8, type ResolvedFarmDevtoolsConfig as a9, type FarmAuthDatabaseConfig as aA, type FarmAuthEmailAndPasswordConfig as aB, type FarmAuthSessionConfig as aC, type FarmAuthUserConfig as aD, type PluginRequestContext as aE, type FarmPluginContext as aF, type FarmRequestPluginContext as aG, type FarmRequestStore as aH, type FarmPluginRuntimeKind as aI, type FarmPluginRouteRuntimePayload as aJ, type FarmPluginSetupContext as aK, type FarmPluginStateContext as aL, type FarmPluginRuntimeBaseEvent as aM, type FarmPluginRuntimeContextEvent as aN, type FarmPluginRuntimeBeforeEvent as aO, type FarmPluginRuntimeAfterEvent as aP, type FarmPluginRuntimeErrorEvent as aQ, type FarmPluginRuntimeStartEvent as aR, type FarmPluginRuntimeCloseEvent as aS, type FarmPluginRuntimeHooks as aT, type FarmPluginRuntimeRequestOptions as aU, type FarmPluginRuntimeRequestHandler as aV, type FarmPluginRuntimeSession as aW, type FarmPluginDiscoveredRoute as aX, type FarmPluginRouterHooks as aY, type FarmPluginRenderHooks as aZ, type FarmPluginBuildHooks as a_, type ResolvedFarmAuthConfig as aa, type ResolvedFarmPerformanceConfig as ab, type ResolvedFarmSecurityConfig as ac, type OpenAPIConfig as ad, definePlugin as ae, PluginManager as af, resolveConfig as ag, loadConfig as ah, resolveDeployConfig as ai, resolveMigrationsConfig as aj, resolveDeployOutputPath as ak, normalizeDeployTarget as al, getDeployTargetForPreset as am, getPresetForDeployTarget as an, type FarmLayerConfig as ao, type FarmPerformanceConfig as ap, type FarmPreloadMode as aq, type FarmPreloadUserConfig as ar, type ResolvedFarmPreloadConfig as as, type FarmCspConfig as at, type FarmCspDirectives as au, type FarmCspDirectiveValue as av, type FarmCspOptions as aw, type FarmSecurityConfig as ax, type ResolvedFarmCspConfig as ay, type FarmAuthConfig as az, type FarmMigrationsConfig as b, type FarmIntegrationSchemaField as b$, type FarmPluginClientConfig as b0, type RouteDiscoveredPayload as b1, type RoutesGeneratedPayload as b2, type MiddlewareDiscoveredPayload as b3, type APIRouteDiscoveredPayload as b4, type RouteMatchPayload as b5, type RouteMatchResultPayload as b6, type RenderLifecyclePayload as b7, type APIHandlerLifecyclePayload as b8, type ErrorLifecyclePayload as b9, type FarmIntegrationInputSchema as bA, type FarmIntegrationRouteInputSchemas as bB, type FarmIntegrationRequestContextStore as bC, FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY as bD, type FarmIntegrationRouteDb as bE, type FarmIntegrationRouteStorageArgs as bF, type FarmIntegrationRouteArgs as bG, type FarmIntegrationConfigContext as bH, type FarmIntegrationConfigDefinition as bI, type FarmIntegrationConfigInput as bJ, type FarmIntegrationLifecycleLogLevel as bK, type FarmIntegrationLifecycleLogger as bL, type FarmIntegrationLifecycleContext as bM, type FarmIntegrationLifecycleHook as bN, type FarmIntegrationData as bO, type FarmIntegrationHandlerContext as bP, type FarmIntegrationRouteHookContext as bQ, type FarmIntegrationRouteHook as bR, type FarmIntegrationRoute as bS, type FarmTypedIntegrationRoute as bT, type FarmIntegrationRouteMiddleware as bU, type FarmIntegrationMiddleware as bV, type FarmIntegrationProviderProps as bW, type FarmIntegrationProvider as bX, type FarmIntegrationDocumentNavigation as bY, type FarmIntegrationSchemaFieldType as bZ, type FarmIntegrationSchemaReference as b_, type HMRUpdatePayload as ba, type BundleLifecyclePayload as bb, type NitroBuildLifecyclePayload as bc, type ShutdownPayload as bd, type ResolvedFarmConfig as be, type RedirectConfig as bf, type HeaderConfig as bg, type RewriteConfig as bh, type ImageConfig as bi, type I18nConfig as bj, type MiddlewareConfig as bk, type FarmDeployConfig as bl, type ResolvedFarmDeployConfig as bm, type FarmDeployTarget as bn, type FarmIntegrationCategory as bo, type FarmIntegrationSlot as bp, type FarmIntegrationRouteParamValue as bq, type FarmIntegrationRouteParams as br, type FarmIntegrationRouteMethod as bs, type FarmIntegrationRouteInputSource as bt, type FarmIntegrationValidationPathSegment as bu, type FarmIntegrationRouteInput as bv, type FarmIntegrationValidationIssue as bw, type FarmIntegrationValidationErrorLike as bx, type FarmIntegrationValidationResult as by, type FarmIntegrationStandardValidationResult as bz, type FarmMigrationsUserConfig as c, type FarmRouteRule as c$, type FarmIntegrationSchemaConstraint as c0, type FarmIntegrationSchemaModel as c1, type FarmIntegrationSchemaModelExtension as c2, type FarmIntegrationSchemaModelOverride as c3, type FarmIntegrationSchema as c4, defineIntegrationSchema as c5, type FarmIntegrationLogPhase as c6, type FarmIntegrationLogEvent as c7, type FarmIntegrationLogger as c8, type FarmIntegrationsUserConfig as c9, type InferFarmIntegrationOrmField as cA, type InferFarmIntegrationOrmFields as cB, type InferFarmIntegrationOrmSchema as cC, type InferFarmIntegrationOrmClient as cD, type CreateIntegrationOrmOptions as cE, createIntegrationOrm as cF, resolveIntegrationOrmRuntimeClient as cG, farmIntegrationSchemaToOrmSchema as cH, type IntegrationOrmModelNames as cI, type MiddlewareContext as cJ, type MiddlewareFunction as cK, type RequestMiddleware as cL, type RequestMiddlewareContext as cM, type MiddlewareStore as cN, type MiddlewareChain as cO, type CookieJar as cP, type CookieOptions as cQ, type RateLimitConfig as cR, type RateLimitIncrementResult as cS, type RateLimitStorage as cT, type RateLimitStatus as cU, type MemoryRateLimitStorageOptions as cV, type NextFunction as cW, type MiddlewareResult as cX, type FarmRouteRuleRenderMode as cY, type FarmRouteRuleRedirect as cZ, type FarmRouteRuleCors as c_, getFarmIntegrationPluginServerRuntime as ca, type FarmIntegrationRouteFactory as cb, type FarmIntegrationRoutesFactoryContext as cc, type FarmIntegrationRoutesFactory as cd, type FarmIntegrationEndpointValue as ce, type FarmIntegrationEndpoints as cf, type FarmIntegrationEndpointsFactoryContext as cg, type FarmIntegrationEndpointsFactory as ch, createIntegrationRoute as ci, integrationRoute as cj, type DefinedIntegration as ck, defineIntegration as cl, isFarmIntegration as cm, resolveIntegrationPlugins as cn, getIntegrationProviders as co, getIntegrationDocumentNavigationMatchers as cp, getIntegrationSchemas as cq, getRegisteredIntegrationRuntime as cr, getRegisteredIntegrations as cs, getRegisteredIntegrationSchemas as ct, matchIntegrationRoute as cu, matchRegisteredIntegrationRoute as cv, getRegisteredIntegrationAPIManifest as cw, dispatchIntegrationRequest as cx, type FarmIntegrationOrmSchema as cy, type FarmIntegrationOrmClient as cz, defineConfig as d, type FarmRouteRules as d0, normalizeRouteRules as d1, routeRulesToRedirects as d2, routeRulesToHeaders as d3, routeRulesToNitroRouteRules as d4, type FarmMdxComponent as d5, type FarmMdxComponents as d6, type FarmMdxUserConfig as d7, type FarmMarkdownPageSource as d8, type FarmMarkdownPageModuleInput as d9, resolveMdxConfig as da, isFarmMarkdownPageFile as db, normalizeFarmMarkdownRoutePath as dc, parseMarkdownFrontmatter as dd, titleFromMarkdown as de, createMarkdownMetadata as df, createFarmMarkdownRouteModule as dg, createFarmMarkdownRouteModuleFromFile as dh, loadFarmMdxComponents as di, createFarmMarkdownSourceResponse as dj, DEFAULT_FARM_DEVTOOLS_SHORTCUT as dk, FARM_DEVTOOLS_PATH as dl, FARM_DEVTOOLS_LAUNCH_PARAM as dm, type FarmDevtoolsConfig as dn, type FarmDevtoolsUserConfig as dp, resolveFarmDevtoolsConfig as dq, type MiddlewareConfig$1 as dr, farmI18nClientBridgePlugin as ds, rewriteEarlySsrRelativeImports as dt, type FarmContextFactoryInput as e, farmPlugin as f, type FarmContextFactory as g, type FarmAppContext as h, type PluginContextProps as i, type PageProps as j, type PagePropsWithMiddleware as k, type LayoutProps as l, type MetadataProps as m, type LayoutMetadataProps as n, type Page as o, type Layout as p, type Loading as q, type ErrorBoundary as r, type RouteModule as s, type StaticPathParams as t, type StaticRouteParams as u, type LayoutModule as v, type Metadata as w, type FarmRequest as x, type FarmResponse as y, type ServerAction as z };
|