@flightdev/core 0.6.7

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.
Files changed (187) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +541 -0
  3. package/dist/actions/index.d.ts +743 -0
  4. package/dist/actions/index.js +3 -0
  5. package/dist/actions/index.js.map +1 -0
  6. package/dist/adapters/index.d.ts +502 -0
  7. package/dist/adapters/index.js +3 -0
  8. package/dist/adapters/index.js.map +1 -0
  9. package/dist/cache/index.d.ts +191 -0
  10. package/dist/cache/index.js +3 -0
  11. package/dist/cache/index.js.map +1 -0
  12. package/dist/chunk-62HISNA3.js +354 -0
  13. package/dist/chunk-62HISNA3.js.map +1 -0
  14. package/dist/chunk-63LWTEDQ.js +341 -0
  15. package/dist/chunk-63LWTEDQ.js.map +1 -0
  16. package/dist/chunk-63SCEXD7.js +3 -0
  17. package/dist/chunk-63SCEXD7.js.map +1 -0
  18. package/dist/chunk-72MYOTUB.js +667 -0
  19. package/dist/chunk-72MYOTUB.js.map +1 -0
  20. package/dist/chunk-7CNW24MQ.js +257 -0
  21. package/dist/chunk-7CNW24MQ.js.map +1 -0
  22. package/dist/chunk-7WIEAUJT.js +300 -0
  23. package/dist/chunk-7WIEAUJT.js.map +1 -0
  24. package/dist/chunk-7ZZF4ULK.js +259 -0
  25. package/dist/chunk-7ZZF4ULK.js.map +1 -0
  26. package/dist/chunk-AE3JTS73.js +222 -0
  27. package/dist/chunk-AE3JTS73.js.map +1 -0
  28. package/dist/chunk-AP5NLUSB.js +258 -0
  29. package/dist/chunk-AP5NLUSB.js.map +1 -0
  30. package/dist/chunk-C37YQQI7.js +221 -0
  31. package/dist/chunk-C37YQQI7.js.map +1 -0
  32. package/dist/chunk-DCLVXFVH.js +225 -0
  33. package/dist/chunk-DCLVXFVH.js.map +1 -0
  34. package/dist/chunk-DZMWWDFD.js +223 -0
  35. package/dist/chunk-DZMWWDFD.js.map +1 -0
  36. package/dist/chunk-GCQZ4FHI.js +245 -0
  37. package/dist/chunk-GCQZ4FHI.js.map +1 -0
  38. package/dist/chunk-IPP44XY6.js +47 -0
  39. package/dist/chunk-IPP44XY6.js.map +1 -0
  40. package/dist/chunk-IW7FTQQX.js +267 -0
  41. package/dist/chunk-IW7FTQQX.js.map +1 -0
  42. package/dist/chunk-JX4YSCBH.js +428 -0
  43. package/dist/chunk-JX4YSCBH.js.map +1 -0
  44. package/dist/chunk-KX6UYWWR.js +229 -0
  45. package/dist/chunk-KX6UYWWR.js.map +1 -0
  46. package/dist/chunk-LWVETFJV.js +46 -0
  47. package/dist/chunk-LWVETFJV.js.map +1 -0
  48. package/dist/chunk-MCL2MCA2.js +285 -0
  49. package/dist/chunk-MCL2MCA2.js.map +1 -0
  50. package/dist/chunk-MZXCF35B.js +205 -0
  51. package/dist/chunk-MZXCF35B.js.map +1 -0
  52. package/dist/chunk-NCGPUFWV.js +96 -0
  53. package/dist/chunk-NCGPUFWV.js.map +1 -0
  54. package/dist/chunk-OEJMIE2Q.js +351 -0
  55. package/dist/chunk-OEJMIE2Q.js.map +1 -0
  56. package/dist/chunk-OYF2OAKS.js +394 -0
  57. package/dist/chunk-OYF2OAKS.js.map +1 -0
  58. package/dist/chunk-P6S43FYZ.js +316 -0
  59. package/dist/chunk-P6S43FYZ.js.map +1 -0
  60. package/dist/chunk-PL37KFRJ.js +3 -0
  61. package/dist/chunk-PL37KFRJ.js.map +1 -0
  62. package/dist/chunk-Q7BS5QC5.js +197 -0
  63. package/dist/chunk-Q7BS5QC5.js.map +1 -0
  64. package/dist/chunk-SDYPG3JD.js +288 -0
  65. package/dist/chunk-SDYPG3JD.js.map +1 -0
  66. package/dist/chunk-SUG56SZO.js +256 -0
  67. package/dist/chunk-SUG56SZO.js.map +1 -0
  68. package/dist/chunk-UVH5XJRP.js +164 -0
  69. package/dist/chunk-UVH5XJRP.js.map +1 -0
  70. package/dist/chunk-WZIJKCL3.js +282 -0
  71. package/dist/chunk-WZIJKCL3.js.map +1 -0
  72. package/dist/chunk-Y22AMGTM.js +3 -0
  73. package/dist/chunk-Y22AMGTM.js.map +1 -0
  74. package/dist/chunk-Z7G23XWU.js +200 -0
  75. package/dist/chunk-Z7G23XWU.js.map +1 -0
  76. package/dist/chunk-ZJU5M4IB.js +125 -0
  77. package/dist/chunk-ZJU5M4IB.js.map +1 -0
  78. package/dist/chunk-ZVC3ZWLM.js +52 -0
  79. package/dist/chunk-ZVC3ZWLM.js.map +1 -0
  80. package/dist/chunk-ZZZML7Y3.js +310 -0
  81. package/dist/chunk-ZZZML7Y3.js.map +1 -0
  82. package/dist/client.d.ts +25 -0
  83. package/dist/client.js +16 -0
  84. package/dist/client.js.map +1 -0
  85. package/dist/config/index.d.ts +170 -0
  86. package/dist/config/index.js +3 -0
  87. package/dist/config/index.js.map +1 -0
  88. package/dist/errors/index.d.ts +267 -0
  89. package/dist/errors/index.js +4 -0
  90. package/dist/errors/index.js.map +1 -0
  91. package/dist/file-router/index.d.ts +184 -0
  92. package/dist/file-router/index.js +3 -0
  93. package/dist/file-router/index.js.map +1 -0
  94. package/dist/file-router/streaming-hints.d.ts +129 -0
  95. package/dist/file-router/streaming-hints.js +3 -0
  96. package/dist/file-router/streaming-hints.js.map +1 -0
  97. package/dist/handlers/index.d.ts +59 -0
  98. package/dist/handlers/index.js +3 -0
  99. package/dist/handlers/index.js.map +1 -0
  100. package/dist/index.d.ts +588 -0
  101. package/dist/index.js +886 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/islands/index.d.ts +234 -0
  104. package/dist/islands/index.js +3 -0
  105. package/dist/islands/index.js.map +1 -0
  106. package/dist/middleware/index.d.ts +305 -0
  107. package/dist/middleware/index.js +3 -0
  108. package/dist/middleware/index.js.map +1 -0
  109. package/dist/react/index.d.ts +73 -0
  110. package/dist/react/index.js +52 -0
  111. package/dist/react/index.js.map +1 -0
  112. package/dist/render/index.d.ts +131 -0
  113. package/dist/render/index.js +3 -0
  114. package/dist/render/index.js.map +1 -0
  115. package/dist/router/index.d.ts +65 -0
  116. package/dist/router/index.js +3 -0
  117. package/dist/router/index.js.map +1 -0
  118. package/dist/rsc/adapters/index.d.ts +8 -0
  119. package/dist/rsc/adapters/index.js +7 -0
  120. package/dist/rsc/adapters/index.js.map +1 -0
  121. package/dist/rsc/adapters/preact.d.ts +97 -0
  122. package/dist/rsc/adapters/preact.js +3 -0
  123. package/dist/rsc/adapters/preact.js.map +1 -0
  124. package/dist/rsc/adapters/react.d.ts +82 -0
  125. package/dist/rsc/adapters/react.js +3 -0
  126. package/dist/rsc/adapters/react.js.map +1 -0
  127. package/dist/rsc/adapters/solid.d.ts +84 -0
  128. package/dist/rsc/adapters/solid.js +3 -0
  129. package/dist/rsc/adapters/solid.js.map +1 -0
  130. package/dist/rsc/adapters/vue.d.ts +80 -0
  131. package/dist/rsc/adapters/vue.js +3 -0
  132. package/dist/rsc/adapters/vue.js.map +1 -0
  133. package/dist/rsc/boundaries.d.ts +182 -0
  134. package/dist/rsc/boundaries.js +3 -0
  135. package/dist/rsc/boundaries.js.map +1 -0
  136. package/dist/rsc/context.d.ts +201 -0
  137. package/dist/rsc/context.js +3 -0
  138. package/dist/rsc/context.js.map +1 -0
  139. package/dist/rsc/index.d.ts +232 -0
  140. package/dist/rsc/index.js +15 -0
  141. package/dist/rsc/index.js.map +1 -0
  142. package/dist/rsc/legacy.d.ts +155 -0
  143. package/dist/rsc/legacy.js +3 -0
  144. package/dist/rsc/legacy.js.map +1 -0
  145. package/dist/rsc/payload.d.ts +262 -0
  146. package/dist/rsc/payload.js +3 -0
  147. package/dist/rsc/payload.js.map +1 -0
  148. package/dist/rsc/plugins/esbuild.d.ts +124 -0
  149. package/dist/rsc/plugins/esbuild.js +4 -0
  150. package/dist/rsc/plugins/esbuild.js.map +1 -0
  151. package/dist/rsc/plugins/index.d.ts +4 -0
  152. package/dist/rsc/plugins/index.js +6 -0
  153. package/dist/rsc/plugins/index.js.map +1 -0
  154. package/dist/rsc/plugins/rollup.d.ts +103 -0
  155. package/dist/rsc/plugins/rollup.js +4 -0
  156. package/dist/rsc/plugins/rollup.js.map +1 -0
  157. package/dist/rsc/renderer.d.ts +162 -0
  158. package/dist/rsc/renderer.js +5 -0
  159. package/dist/rsc/renderer.js.map +1 -0
  160. package/dist/rsc/stream.d.ts +129 -0
  161. package/dist/rsc/stream.js +3 -0
  162. package/dist/rsc/stream.js.map +1 -0
  163. package/dist/rsc/vite-plugin.d.ts +78 -0
  164. package/dist/rsc/vite-plugin.js +4 -0
  165. package/dist/rsc/vite-plugin.js.map +1 -0
  166. package/dist/server/index.d.ts +135 -0
  167. package/dist/server/index.js +6 -0
  168. package/dist/server/index.js.map +1 -0
  169. package/dist/streaming/adapters/index.d.ts +223 -0
  170. package/dist/streaming/adapters/index.js +3 -0
  171. package/dist/streaming/adapters/index.js.map +1 -0
  172. package/dist/streaming/conditional.d.ts +130 -0
  173. package/dist/streaming/conditional.js +3 -0
  174. package/dist/streaming/conditional.js.map +1 -0
  175. package/dist/streaming/index.d.ts +177 -0
  176. package/dist/streaming/index.js +3 -0
  177. package/dist/streaming/index.js.map +1 -0
  178. package/dist/streaming/observability.d.ts +201 -0
  179. package/dist/streaming/observability.js +4 -0
  180. package/dist/streaming/observability.js.map +1 -0
  181. package/dist/streaming/priority.d.ts +103 -0
  182. package/dist/streaming/priority.js +3 -0
  183. package/dist/streaming/priority.js.map +1 -0
  184. package/dist/utils/index.d.ts +42 -0
  185. package/dist/utils/index.js +4 -0
  186. package/dist/utils/index.js.map +1 -0
  187. package/package.json +228 -0
@@ -0,0 +1,3 @@
1
+ export { RedirectError, clearActions, collectStream, cookies, createActionContext, createActionMiddleware, createActionReference, createLoggingMiddleware, createMemoryAdapter, createProgressReporter, createQueueManager, createQueuedAction, createRetryMiddleware, createStreamableAction, createTimingMiddleware, defaultRetryStrategy, executeAction, executeFormAction, executeWithMiddleware, exponentialBackoff, fixedDelay, generateActionId, getAction, getAllActions, handleActionRequest, isRedirectError, parseFormData, pipeline, redirect, registerAction, responseToStream, streamToResponse } from '../chunk-72MYOTUB.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,502 @@
1
+ import { UIFrameworkAdapter, RenderContext, RenderResult } from '../render/index.js';
2
+
3
+ /**
4
+ * Flight Universal Handler - Platform-agnostic request handler
5
+ *
6
+ * This is the core abstraction that allows Flight applications to run anywhere.
7
+ * Adapters can use this handler, or implement their own - zero lock-in.
8
+ *
9
+ * @module @flightdev/core/adapters/handler
10
+ */
11
+
12
+ /**
13
+ * Route rules for per-path configuration
14
+ * Similar to Nitro's routeRules - completely optional to use
15
+ */
16
+ interface RouteRules {
17
+ [pattern: string]: RouteRuleConfig;
18
+ }
19
+ interface RouteRuleConfig {
20
+ /** Cache configuration */
21
+ cache?: {
22
+ /** Max age in seconds */
23
+ maxAge?: number;
24
+ /** Stale-while-revalidate in seconds */
25
+ swr?: number;
26
+ /** Vary headers */
27
+ vary?: string[];
28
+ };
29
+ /** CORS configuration */
30
+ cors?: boolean | CorsOptions;
31
+ /** Headers to add to response */
32
+ headers?: Record<string, string>;
33
+ /** Redirect configuration */
34
+ redirect?: string | {
35
+ to: string;
36
+ statusCode?: 301 | 302 | 303 | 307 | 308;
37
+ };
38
+ /** Proxy to another URL */
39
+ proxy?: string;
40
+ /** Render mode override */
41
+ render?: 'ssr' | 'ssg' | 'csr' | 'isr';
42
+ /** ISR revalidation time in seconds */
43
+ isr?: number;
44
+ /** Prerender at build time */
45
+ prerender?: boolean;
46
+ }
47
+ interface CorsOptions {
48
+ origin?: string | string[] | boolean;
49
+ methods?: string[];
50
+ allowedHeaders?: string[];
51
+ exposedHeaders?: string[];
52
+ credentials?: boolean;
53
+ maxAge?: number;
54
+ }
55
+ /**
56
+ * Handler options - all optional, user configures what they need
57
+ */
58
+ interface UniversalHandlerOptions {
59
+ /** Route manifest from build */
60
+ manifest?: RouteManifest;
61
+ /** UI framework adapter (optional - for SSR) */
62
+ framework?: UIFrameworkAdapter;
63
+ /** Route rules (optional) */
64
+ routeRules?: RouteRules;
65
+ /** Static files directory (optional) */
66
+ staticDir?: string;
67
+ /** Base path (optional) */
68
+ basePath?: string;
69
+ /** Custom error handler (optional) */
70
+ onError?: (error: Error, request: Request) => Response | Promise<Response>;
71
+ /** Custom not found handler (optional) */
72
+ onNotFound?: (request: Request) => Response | Promise<Response>;
73
+ /** Hooks for extensibility (optional) */
74
+ hooks?: HandlerHooks;
75
+ }
76
+ /**
77
+ * Handler hooks for extensibility - all optional
78
+ */
79
+ interface HandlerHooks {
80
+ /** Before handling request */
81
+ beforeHandle?: (request: Request) => Request | Promise<Request> | void;
82
+ /** After getting response, before sending */
83
+ afterHandle?: (request: Request, response: Response) => Response | Promise<Response> | void;
84
+ /** Before SSR render */
85
+ beforeRender?: (context: RenderContext) => void | Promise<void>;
86
+ /** After SSR render */
87
+ afterRender?: (result: RenderResult) => RenderResult | Promise<RenderResult>;
88
+ }
89
+ /**
90
+ * Route manifest from build
91
+ */
92
+ interface RouteManifest {
93
+ routes: Array<{
94
+ path: string;
95
+ component: string;
96
+ mode: 'ssr' | 'ssg' | 'csr' | 'isr';
97
+ handler?: string;
98
+ }>;
99
+ staticFiles?: string[];
100
+ }
101
+ /**
102
+ * Universal handler interface
103
+ */
104
+ interface UniversalHandler {
105
+ /** Handle a fetch request */
106
+ fetch(request: Request, env?: unknown, ctx?: unknown): Promise<Response>;
107
+ /** Check if this handler can handle the request */
108
+ canHandle(request: Request): boolean;
109
+ }
110
+ /**
111
+ * Create a universal request handler
112
+ *
113
+ * This is the main abstraction for handling requests.
114
+ * Adapters can use this, extend it, or ignore it completely.
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * // Using the handler (optional)
119
+ * import { createUniversalHandler } from '@flightdev/core/adapters';
120
+ *
121
+ * const handler = createUniversalHandler({
122
+ * manifest: await import('./manifest.json'),
123
+ * routeRules: {
124
+ * '/api/**': { cors: true },
125
+ * '/blog/**': { cache: { maxAge: 3600 } },
126
+ * },
127
+ * });
128
+ *
129
+ * // In your adapter
130
+ * export default {
131
+ * fetch: handler.fetch,
132
+ * };
133
+ * ```
134
+ */
135
+ declare function createUniversalHandler(options?: UniversalHandlerOptions): UniversalHandler;
136
+
137
+ /**
138
+ * Flight Adapters - Optional Validation Helpers
139
+ *
140
+ * This module provides optional validation utilities for adapter options.
141
+ * Zod is NOT required - these are only used if the developer chooses to
142
+ * add runtime validation to their adapter.
143
+ *
144
+ * @example Without validation (default - no Zod needed)
145
+ * ```typescript
146
+ * import { createAdapter } from '@flightdev/core/adapters';
147
+ *
148
+ * export default function myAdapter(options = {}) {
149
+ * return createAdapter({
150
+ * name: 'my-adapter',
151
+ * adapt: async (builder) => { ... }
152
+ * });
153
+ * }
154
+ * ```
155
+ *
156
+ * @example With optional Zod validation (if developer wants it)
157
+ * ```typescript
158
+ * import { createValidatedAdapter } from '@flightdev/core/adapters';
159
+ * import { z } from 'zod';
160
+ *
161
+ * const optionsSchema = z.object({
162
+ * port: z.number().default(3000),
163
+ * healthCheck: z.boolean().default(true),
164
+ * });
165
+ *
166
+ * export default createValidatedAdapter(
167
+ * 'my-adapter',
168
+ * optionsSchema,
169
+ * (options) => ({
170
+ * adapt: async (builder) => { ... }
171
+ * })
172
+ * );
173
+ * ```
174
+ *
175
+ * @module @flightdev/core/adapters/validation
176
+ */
177
+
178
+ /**
179
+ * Minimal Zod-like schema interface
180
+ * This allows the validation helper to work with Zod or any compatible library
181
+ * without requiring Zod as a direct dependency
182
+ */
183
+ interface ZodLikeSchema<T = unknown> {
184
+ parse(data: unknown): T;
185
+ safeParse(data: unknown): {
186
+ success: true;
187
+ data: T;
188
+ } | {
189
+ success: false;
190
+ error: unknown;
191
+ };
192
+ }
193
+ /**
194
+ * Options for validated adapter factory
195
+ */
196
+ interface ValidatedAdapterOptions<T> {
197
+ /** Parsed and validated options */
198
+ adapt: (builder: AdapterBuilder) => Promise<void>;
199
+ /** Optional emulate function */
200
+ emulate?: FlightAdapter['emulate'];
201
+ /** Optional supports declaration */
202
+ supports?: FlightAdapter['supports'];
203
+ }
204
+ /**
205
+ * Create a validated adapter factory
206
+ *
207
+ * This helper validates adapter options at runtime using a Zod-like schema.
208
+ * The developer chooses whether to use this - it's completely optional.
209
+ *
210
+ * @param name - Adapter name
211
+ * @param schema - Zod-like schema for options validation
212
+ * @param factory - Factory function that receives validated options
213
+ * @returns Adapter factory function
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * import { createValidatedAdapter } from '@flightdev/core/adapters';
218
+ * import { z } from 'zod';
219
+ *
220
+ * const schema = z.object({
221
+ * port: z.number().default(3000),
222
+ * region: z.string().optional(),
223
+ * });
224
+ *
225
+ * export default createValidatedAdapter('my-adapter', schema, (options) => ({
226
+ * adapt: async (builder) => {
227
+ * // options is fully typed: { port: number; region?: string }
228
+ * console.log(`Using port ${options.port}`);
229
+ * }
230
+ * }));
231
+ * ```
232
+ */
233
+ declare function createValidatedAdapter<TSchema extends ZodLikeSchema>(name: string, schema: TSchema, factory: (options: ReturnType<TSchema['parse']>) => ValidatedAdapterOptions<ReturnType<TSchema['parse']>>): (options?: unknown) => FlightAdapter;
234
+ /**
235
+ * Validate adapter options without throwing
236
+ * Returns null if validation fails, useful for optional validation
237
+ *
238
+ * @param schema - Zod-like schema
239
+ * @param options - Options to validate
240
+ * @returns Validated options or null
241
+ */
242
+ declare function validateAdapterOptions<TSchema extends ZodLikeSchema>(schema: TSchema, options: unknown): ReturnType<TSchema['parse']> | null;
243
+ /**
244
+ * Assert adapter options are valid, throwing detailed error if not
245
+ *
246
+ * @param name - Adapter name for error messages
247
+ * @param schema - Zod-like schema
248
+ * @param options - Options to validate
249
+ * @returns Validated options
250
+ * @throws Error with detailed message if validation fails
251
+ */
252
+ declare function assertValidOptions<TSchema extends ZodLikeSchema>(name: string, schema: TSchema, options: unknown): ReturnType<TSchema['parse']>;
253
+ /**
254
+ * Extract the inferred type from a Zod-like schema
255
+ * Useful for typing adapter options in TypeScript
256
+ */
257
+ type InferSchema<T extends ZodLikeSchema> = ReturnType<T['parse']>;
258
+
259
+ /**
260
+ * Flight Adapters - Universal deployment adapters
261
+ *
262
+ * Adapters transform Flight's output for different deployment targets.
263
+ * The user chooses where to deploy - Flight provides the adapters.
264
+ */
265
+ /** Build manifest containing all generated assets */
266
+ interface BuildManifest {
267
+ /** Entry points by name */
268
+ entries: Record<string, string>;
269
+ /** All generated files */
270
+ files: string[];
271
+ /** Route information */
272
+ routes: RouteManifestEntry[];
273
+ /** Server entry point (if applicable) */
274
+ serverEntry?: string;
275
+ /** Client entry point */
276
+ clientEntry?: string;
277
+ }
278
+ /** Route information in manifest */
279
+ interface RouteManifestEntry {
280
+ /** Route path pattern */
281
+ path: string;
282
+ /** Render mode for this route */
283
+ mode: 'ssr' | 'ssg' | 'csr' | 'isr';
284
+ /** Component/handler file path */
285
+ component: string;
286
+ /** Pre-rendered paths (for SSG/ISR) */
287
+ prerendered?: string[];
288
+ }
289
+ /** Builder utilities passed to adapters */
290
+ interface AdapterBuilder {
291
+ /** Build manifest */
292
+ manifest: BuildManifest;
293
+ /** Project root directory */
294
+ root: string;
295
+ /** Build output directory */
296
+ outDir: string;
297
+ /** Read a file from the build output */
298
+ readFile(path: string): Promise<string>;
299
+ /** Write a file to the adapter output */
300
+ writeFile(path: string, content: string): Promise<void>;
301
+ /** Copy files from build to adapter output */
302
+ copy(from: string, to: string): Promise<void>;
303
+ /** Get all files matching a pattern */
304
+ glob(pattern: string): Promise<string[]>;
305
+ /** Compress files for production */
306
+ compress?(files: string[]): Promise<void>;
307
+ /** Log info message */
308
+ log: {
309
+ info(message: string): void;
310
+ warn(message: string): void;
311
+ error(message: string): void;
312
+ };
313
+ }
314
+ /** Flight adapter interface */
315
+ interface FlightAdapter {
316
+ /** Adapter name */
317
+ name: string;
318
+ /**
319
+ * Transform the build output for the target platform
320
+ * This is called after Flight's build process completes
321
+ */
322
+ adapt(builder: AdapterBuilder): Promise<void>;
323
+ /**
324
+ * Optional: Start listening for requests (for Node.js/Bun adapters)
325
+ */
326
+ listen?(server: unknown, port: number): Promise<void>;
327
+ /**
328
+ * Optional: Emulate the platform during development
329
+ * Useful for testing platform-specific behavior locally
330
+ */
331
+ emulate?(): {
332
+ /** Platform-specific env vars */
333
+ env?: Record<string, string>;
334
+ /** Custom middleware for dev server */
335
+ middleware?: unknown[];
336
+ };
337
+ /**
338
+ * Optional: Declare what this adapter supports
339
+ * Flight uses this to warn about incompatible features
340
+ */
341
+ supports?: {
342
+ /** Can read files at runtime (for dynamic content) */
343
+ read?: () => boolean;
344
+ /** Supports streaming responses */
345
+ streaming?: () => boolean;
346
+ /** Supports WebSockets */
347
+ websockets?: () => boolean;
348
+ /** Supports edge runtime */
349
+ edge?: () => boolean;
350
+ /** Supports Node.js runtime */
351
+ node?: () => boolean;
352
+ };
353
+ }
354
+ interface AdapterOptions {
355
+ name: string;
356
+ adapt: (builder: AdapterBuilder) => Promise<void>;
357
+ emulate?: FlightAdapter['emulate'];
358
+ supports?: FlightAdapter['supports'];
359
+ }
360
+ /**
361
+ * Create a Flight adapter
362
+ *
363
+ * @example
364
+ * ```typescript
365
+ * import { createAdapter } from '@flightdev/core/adapters';
366
+ *
367
+ * export default function myAdapter(options = {}) {
368
+ * return createAdapter({
369
+ * name: 'my-adapter',
370
+ * async adapt(builder) {
371
+ * // Transform build output for your platform
372
+ * },
373
+ * });
374
+ * }
375
+ * ```
376
+ */
377
+ declare function createAdapter(options: AdapterOptions): FlightAdapter;
378
+
379
+ /**
380
+ * Storage Adapter Interface
381
+ *
382
+ * Implement this to use any storage provider:
383
+ * S3, Supabase Storage, Cloudflare R2, local filesystem, etc.
384
+ */
385
+ interface StorageAdapter {
386
+ name: string;
387
+ /** Upload a file */
388
+ upload(path: string, data: Buffer | Uint8Array | string, options?: {
389
+ contentType?: string;
390
+ metadata?: Record<string, string>;
391
+ }): Promise<{
392
+ url: string;
393
+ path: string;
394
+ }>;
395
+ /** Download a file */
396
+ download(path: string): Promise<Buffer>;
397
+ /** Delete a file */
398
+ delete(path: string): Promise<void>;
399
+ /** List files with optional prefix */
400
+ list(prefix?: string): Promise<string[]>;
401
+ /** Get a signed URL for direct access */
402
+ getSignedUrl?(path: string, options?: {
403
+ expiresIn?: number;
404
+ operation?: 'read' | 'write';
405
+ }): Promise<string>;
406
+ }
407
+ /**
408
+ * Auth Adapter Interface
409
+ *
410
+ * Implement this to use any auth provider:
411
+ * Better Auth, Supabase Auth, Lucia, Auth.js, etc.
412
+ */
413
+ interface AuthAdapter {
414
+ name: string;
415
+ /** Get the current user from a request */
416
+ getUser(request: Request): Promise<AuthUser | null>;
417
+ /** Verify a session token */
418
+ verifySession(token: string): Promise<AuthSession | null>;
419
+ /** Optional middleware for handling auth-specific routes (e.g., /api/auth/*) */
420
+ middleware?: (req: Request) => Promise<Response | null>;
421
+ }
422
+ interface AuthUser {
423
+ id: string;
424
+ email?: string;
425
+ name?: string;
426
+ avatar?: string;
427
+ metadata?: Record<string, unknown>;
428
+ }
429
+ interface AuthSession {
430
+ user: AuthUser;
431
+ expiresAt: Date;
432
+ token: string;
433
+ }
434
+ /**
435
+ * Email Adapter Interface
436
+ *
437
+ * Implement this to use any email provider:
438
+ * Resend, SendGrid, Postmark, SMTP, etc.
439
+ */
440
+ interface EmailAdapter {
441
+ name: string;
442
+ /** Send an email */
443
+ send(options: {
444
+ to: string | string[];
445
+ subject: string;
446
+ html?: string;
447
+ text?: string;
448
+ from?: string;
449
+ replyTo?: string;
450
+ attachments?: Array<{
451
+ filename: string;
452
+ content: Buffer | string;
453
+ contentType?: string;
454
+ }>;
455
+ }): Promise<{
456
+ id: string;
457
+ success: boolean;
458
+ }>;
459
+ }
460
+ /**
461
+ * Queue/Jobs Adapter Interface
462
+ *
463
+ * Implement this to use any job queue:
464
+ * BullMQ, Quirrel, Inngest, custom, etc.
465
+ */
466
+ interface JobsAdapter {
467
+ name: string;
468
+ /** Add a job to the queue */
469
+ enqueue<T>(jobName: string, data: T, options?: {
470
+ delay?: number;
471
+ priority?: number;
472
+ retries?: number;
473
+ }): Promise<{
474
+ id: string;
475
+ }>;
476
+ /** Schedule a recurring job */
477
+ schedule?(jobName: string, cron: string, data?: unknown): Promise<{
478
+ id: string;
479
+ }>;
480
+ /** Cancel a job */
481
+ cancel?(jobId: string): Promise<void>;
482
+ }
483
+ /**
484
+ * Database Adapter Interface
485
+ *
486
+ * Note: This is intentionally minimal.
487
+ * For databases, use your preferred ORM/query builder directly.
488
+ * This interface is for Flight's internal use (sessions, cache, etc.)
489
+ */
490
+ interface DatabaseAdapter {
491
+ name: string;
492
+ /** Raw query execution */
493
+ query<T = unknown>(sql: string, params?: unknown[]): Promise<T[]>;
494
+ /** Execute a mutation */
495
+ execute(sql: string, params?: unknown[]): Promise<{
496
+ rowsAffected: number;
497
+ }>;
498
+ /** Transaction support */
499
+ transaction?<T>(fn: (tx: DatabaseAdapter) => Promise<T>): Promise<T>;
500
+ }
501
+
502
+ export { type AdapterBuilder, type AdapterOptions, type AuthAdapter, type AuthSession, type AuthUser, type BuildManifest, type CorsOptions, type DatabaseAdapter, type EmailAdapter, type FlightAdapter, type HandlerHooks, type InferSchema, type JobsAdapter, type RouteManifest, type RouteManifestEntry, type RouteRuleConfig, type RouteRules, type StorageAdapter, type UniversalHandler, type UniversalHandlerOptions, type ValidatedAdapterOptions, type ZodLikeSchema, assertValidOptions, createAdapter, createUniversalHandler, createValidatedAdapter, validateAdapterOptions };
@@ -0,0 +1,3 @@
1
+ export { assertValidOptions, createAdapter, createUniversalHandler, createValidatedAdapter, validateAdapterOptions } from '../chunk-62HISNA3.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}