@websublime/vite-plugin-open-api-server 0.24.0-next.5 → 0.24.0-next.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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Plugin, ViteDevServer } from 'vite';
2
- import { Logger, SpecInfo, OpenApiServer, HandlerFn, AnySeedFn } from '@websublime/vite-plugin-open-api-core';
2
+ import { Logger, SpecInfo, OpenApiServer, WebSocketHub, HandlerFn, AnySeedFn } from '@websublime/vite-plugin-open-api-core';
3
3
  export { HandlerContext, HandlerDefinition, HandlerFn, HandlerReturn, SecurityContext, SeedContext, SeedDefinition, SeedFn, SeedHelper, defineHandlers, defineSeeds } from '@websublime/vite-plugin-open-api-core';
4
4
  import { OpenAPIV3_1 } from '@scalar/openapi-types';
5
5
  import { Hono } from 'hono';
@@ -510,6 +510,19 @@ interface OrchestratorResult {
510
510
  instances: SpecInstance[];
511
511
  /** Spec metadata array for WebSocket `connected` event */
512
512
  specsInfo: SpecInfo[];
513
+ /**
514
+ * Shared WebSocket hub for the orchestrator.
515
+ *
516
+ * Created with `autoConnect: false` so the orchestrator controls
517
+ * the `connected` event (enhanced with `specs` metadata).
518
+ *
519
+ * In multi-spec mode (Epic 3, Task 3.1), this hub will be replaced by
520
+ * `createMultiSpecWebSocketHub()` which also wires broadcast interception
521
+ * and multi-spec command routing.
522
+ *
523
+ * @experimental Will be replaced by `createMultiSpecWebSocketHub()` in Epic 3.
524
+ */
525
+ wsHub: WebSocketHub;
513
526
  /** Start the shared HTTP server on the configured port */
514
527
  start(): Promise<void>;
515
528
  /** Stop the HTTP server and clean up resources */
@@ -712,14 +725,12 @@ declare function getSeedFiles(seedsDir: string, cwd?: string): Promise<string[]>
712
725
  /**
713
726
  * Hot Reload
714
727
  *
715
- * What: File watcher for hot reloading handlers and seeds
716
- * How: Uses chokidar to watch for file changes
717
- * Why: Enables rapid development iteration without server restart
728
+ * What: File watcher for hot reloading handlers and seeds with per-spec isolation
729
+ * How: Uses chokidar to watch for file changes, one watcher per spec instance
730
+ * Why: Enables rapid development iteration without server restart; per-spec
731
+ * isolation ensures handler/seed changes in one spec don't affect others
718
732
  *
719
733
  * @module hot-reload
720
- *
721
- * TODO: Full implementation in Task 3.3
722
- * This module provides placeholder/basic functionality for Task 3.1
723
734
  */
724
735
 
725
736
  /**
@@ -782,6 +793,14 @@ interface FileWatcher {
782
793
  * @returns Promise resolving to file watcher instance
783
794
  */
784
795
  declare function createFileWatcher(options: FileWatcherOptions): Promise<FileWatcher>;
796
+ /**
797
+ * Debounced function with cancel support
798
+ */
799
+ interface DebouncedFunction<T extends (...args: unknown[]) => unknown> {
800
+ (...args: Parameters<T>): void;
801
+ /** Cancel any pending debounce timer and queued execution */
802
+ cancel(): void;
803
+ }
785
804
  /**
786
805
  * Debounce a function with async execution guard
787
806
  *
@@ -795,9 +814,50 @@ declare function createFileWatcher(options: FileWatcherOptions): Promise<FileWat
795
814
  *
796
815
  * @param fn - Function to debounce (can be sync or async)
797
816
  * @param delay - Debounce delay in milliseconds
798
- * @returns Debounced function
817
+ * @returns Debounced function with cancel() method
818
+ */
819
+ declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): DebouncedFunction<T>;
820
+ /**
821
+ * Create file watchers for all spec instances
822
+ *
823
+ * Each spec gets independent watchers for its handlers and seeds directories.
824
+ * Changes to one spec's files only trigger reload for that spec instance.
825
+ *
826
+ * @param instances - All spec instances to watch
827
+ * @param vite - Vite dev server (for ssrLoadModule / module invalidation)
828
+ * @param cwd - Project root directory
829
+ * @param options - Resolved plugin options
830
+ * @returns Promise resolving to array of file watchers (one per spec)
831
+ */
832
+ declare function createPerSpecFileWatchers(instances: SpecInstance[], vite: ViteDevServer, cwd: string, options: ResolvedOptions): Promise<FileWatcher[]>;
833
+ /**
834
+ * Reload handlers for a specific spec instance
835
+ *
836
+ * Loads fresh handlers from disk via Vite's ssrLoadModule, updates
837
+ * the spec's server, broadcasts a WebSocket event, and logs the result.
838
+ *
839
+ * @param instance - The spec instance to reload handlers for
840
+ * @param vite - Vite dev server
841
+ * @param cwd - Project root directory
842
+ * @param options - Resolved plugin options
843
+ */
844
+ declare function reloadSpecHandlers(instance: SpecInstance, vite: ViteDevServer, cwd: string, options: ResolvedOptions): Promise<void>;
845
+ /**
846
+ * Reload seeds for a specific spec instance
847
+ *
848
+ * Loads fresh seeds from disk, clears the spec's store, and re-executes
849
+ * seeds. Broadcasts a WebSocket event and logs the result.
850
+ *
851
+ * Note: This operation is not fully atomic — there's a brief window between
852
+ * clearing the store and repopulating it where requests may see empty data.
853
+ * For development tooling, this tradeoff is acceptable.
854
+ *
855
+ * @param instance - The spec instance to reload seeds for
856
+ * @param vite - Vite dev server
857
+ * @param cwd - Project root directory
858
+ * @param options - Resolved plugin options
799
859
  */
800
- declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (...args: Parameters<T>) => void;
860
+ declare function reloadSpecSeeds(instance: SpecInstance, vite: ViteDevServer, cwd: string, options: ResolvedOptions): Promise<void>;
801
861
 
802
862
  /**
803
863
  * Vue DevTools Integration
@@ -880,4 +940,4 @@ declare function registerDevTools(app: App, options?: RegisterDevToolsOptions):
880
940
  */
881
941
  declare function getDevToolsUrl(port?: number, host?: string, protocol?: 'http' | 'https'): string;
882
942
 
883
- export { API_PROXY_PATH, DEVTOOLS_PROXY_PATH, type DeriveProxyPathResult, type FileWatcher, type FileWatcherOptions, type LoadHandlersResult, type LoadSeedsResult, type OpenApiServerOptions, type OrchestratorResult, type ProxyPathSource, type RegisterDevToolsOptions, type ResolvedOptions, type ResolvedSpecConfig, SPEC_COLORS, type SpecConfig, type SpecInstance, ValidationError, type ValidationErrorCode, WS_PROXY_PATH, configureMultiProxy, createFileWatcher, createOrchestrator, debounce, deriveProxyPath, deriveSpecId, getDevToolsUrl, getHandlerFiles, getSeedFiles, loadHandlers, loadSeeds, normalizeProxyPath, openApiServer, registerDevTools, resolveOptions, slugify, validateSpecs, validateUniqueIds, validateUniqueProxyPaths };
943
+ export { API_PROXY_PATH, DEVTOOLS_PROXY_PATH, type DebouncedFunction, type DeriveProxyPathResult, type FileWatcher, type FileWatcherOptions, type LoadHandlersResult, type LoadSeedsResult, type OpenApiServerOptions, type OrchestratorResult, type ProxyPathSource, type RegisterDevToolsOptions, type ResolvedOptions, type ResolvedSpecConfig, SPEC_COLORS, type SpecConfig, type SpecInstance, ValidationError, type ValidationErrorCode, WS_PROXY_PATH, configureMultiProxy, createFileWatcher, createOrchestrator, createPerSpecFileWatchers, debounce, deriveProxyPath, deriveSpecId, getDevToolsUrl, getHandlerFiles, getSeedFiles, loadHandlers, loadSeeds, normalizeProxyPath, openApiServer, registerDevTools, reloadSpecHandlers, reloadSpecSeeds, resolveOptions, slugify, validateSpecs, validateUniqueIds, validateUniqueProxyPaths };