@sylphx/lens-server 4.0.0 → 4.1.0

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.
@@ -196,19 +196,45 @@ export interface WebSocketLike {
196
196
  // =============================================================================
197
197
 
198
198
  /**
199
- * Lens server interface - Pure Executor
199
+ * Lens server interface - Callable HTTP handler with executor methods
200
200
  *
201
- * The server is a pure operation executor. It receives operations and returns results.
202
- * Runtime concerns (connections, transport, protocol) are handled by adapters/handlers.
201
+ * The app itself is a fetch handler. Just pass it directly to your runtime.
203
202
  *
204
- * Core methods:
205
- * - getMetadata() - Server metadata for transport handshake
206
- * - execute() - Execute any operation (returns Observable)
203
+ * @example
204
+ * ```typescript
205
+ * const app = createApp({ router, context: () => ({}) })
207
206
  *
208
- * For handlers that need plugin integration (WS, SSE with state management),
209
- * use getPluginManager() to access plugin hooks directly.
207
+ * // Bun - app is directly usable as handler
208
+ * Bun.serve(app)
209
+ *
210
+ * // Or with explicit fetch
211
+ * Bun.serve({ fetch: app.fetch })
212
+ *
213
+ * // Deno
214
+ * Deno.serve(app)
215
+ *
216
+ * // Cloudflare Workers
217
+ * export default app
218
+ * ```
210
219
  */
211
220
  export interface LensServer {
221
+ /**
222
+ * Call the app directly as a fetch handler.
223
+ * This makes the app callable: `app(request)` or `Bun.serve(app)`
224
+ */
225
+ (request: Request): Promise<Response>;
226
+
227
+ /**
228
+ * HTTP fetch handler - Web standard Request/Response.
229
+ * Same as calling app directly: `app.fetch(req)` === `app(req)`
230
+ *
231
+ * Endpoints:
232
+ * - POST / → Execute operations
233
+ * - GET /__lens/metadata → Server metadata
234
+ * - GET /__lens/health → Health check
235
+ */
236
+ fetch: (request: Request) => Promise<Response>;
237
+
212
238
  /** Get server metadata for transport handshake */
213
239
  getMetadata(): ServerMetadata;
214
240