@websublime/vite-plugin-open-api-server 0.23.0 → 0.24.0-next.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.
- package/dist/index.d.ts +118 -83
- package/dist/index.js +61 -23
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -7,165 +7,200 @@ import { App } from 'vue';
|
|
|
7
7
|
* Vite Plugin Types
|
|
8
8
|
*
|
|
9
9
|
* What: Type definitions for the OpenAPI server Vite plugin
|
|
10
|
-
* How: Defines configuration options and
|
|
10
|
+
* How: Defines configuration options, resolved types, and validation errors
|
|
11
11
|
* Why: Provides type safety and documentation for plugin consumers
|
|
12
12
|
*
|
|
13
13
|
* @module types
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Error codes for configuration validation errors.
|
|
18
|
+
*
|
|
19
|
+
* Used across Tasks 1.2–1.4 for typed error handling.
|
|
20
|
+
* Matches TECHNICAL-SPECIFICATION-V2.md Appendix B.
|
|
21
|
+
*/
|
|
22
|
+
type ValidationErrorCode = 'SPEC_ID_MISSING' | 'SPEC_ID_DUPLICATE' | 'PROXY_PATH_MISSING' | 'PROXY_PATH_TOO_BROAD' | 'PROXY_PATH_DUPLICATE' | 'PROXY_PATH_OVERLAP' | 'SPEC_NOT_FOUND' | 'SPECS_EMPTY';
|
|
23
|
+
/**
|
|
24
|
+
* Typed validation error for configuration issues.
|
|
25
|
+
*
|
|
26
|
+
* Thrown by resolveOptions() and validation functions in spec-id.ts
|
|
27
|
+
* and proxy-path.ts. Consumers can catch and inspect the `code` field
|
|
28
|
+
* for programmatic error handling.
|
|
18
29
|
*
|
|
19
30
|
* @example
|
|
20
31
|
* ```typescript
|
|
21
|
-
*
|
|
32
|
+
* try {
|
|
33
|
+
* resolveOptions({ specs: [] });
|
|
34
|
+
* } catch (error) {
|
|
35
|
+
* if (error instanceof ValidationError && error.code === 'SPECS_EMPTY') {
|
|
36
|
+
* // handle empty specs
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare class ValidationError extends Error {
|
|
42
|
+
readonly code: ValidationErrorCode;
|
|
43
|
+
constructor(code: ValidationErrorCode, message: string);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Configuration for a single OpenAPI spec instance
|
|
22
47
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* });
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const petstore: SpecConfig = {
|
|
51
|
+
* spec: './openapi/petstore.yaml',
|
|
52
|
+
* id: 'petstore',
|
|
53
|
+
* proxyPath: '/api/v3',
|
|
54
|
+
* handlersDir: './mocks/petstore/handlers',
|
|
55
|
+
* seedsDir: './mocks/petstore/seeds',
|
|
56
|
+
* idFields: { Pet: 'petId' },
|
|
57
|
+
* };
|
|
34
58
|
* ```
|
|
35
59
|
*/
|
|
36
|
-
interface
|
|
60
|
+
interface SpecConfig {
|
|
37
61
|
/**
|
|
38
62
|
* Path to OpenAPI spec file (required)
|
|
39
63
|
*
|
|
40
|
-
* Supports:
|
|
41
|
-
* - Local file paths (relative or absolute)
|
|
42
|
-
* - URLs (http:// or https://)
|
|
43
|
-
* - YAML or JSON format
|
|
64
|
+
* Supports: file paths, URLs, YAML, JSON
|
|
44
65
|
*
|
|
45
66
|
* @example './openapi/petstore.yaml'
|
|
46
67
|
* @example 'https://petstore3.swagger.io/api/v3/openapi.json'
|
|
47
68
|
*/
|
|
48
69
|
spec: string;
|
|
49
70
|
/**
|
|
50
|
-
*
|
|
71
|
+
* Unique identifier for this spec instance
|
|
51
72
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
73
|
+
* Used for routing, DevTools grouping, logging, default directory names.
|
|
74
|
+
* If omitted, auto-derived from spec's info.title (slugified).
|
|
54
75
|
*
|
|
55
|
-
* @
|
|
76
|
+
* @example 'petstore'
|
|
56
77
|
*/
|
|
57
|
-
|
|
78
|
+
id?: string;
|
|
58
79
|
/**
|
|
59
80
|
* Base path for request proxy
|
|
60
81
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
82
|
+
* If omitted, auto-derived from spec's servers[0].url.
|
|
83
|
+
* Must be unique across all specs.
|
|
63
84
|
*
|
|
64
85
|
* @example '/api/v3'
|
|
65
|
-
* @default '/api'
|
|
66
86
|
*/
|
|
67
87
|
proxyPath?: string;
|
|
68
88
|
/**
|
|
69
|
-
* Directory containing handler files
|
|
70
|
-
*
|
|
71
|
-
* Handler files should export an object with operationId keys
|
|
72
|
-
* and handler functions as values. Use `defineHandlers()` for
|
|
73
|
-
* type-safe handler definitions.
|
|
74
|
-
*
|
|
75
|
-
* @example './mocks/handlers'
|
|
76
|
-
* @default './mocks/handlers'
|
|
89
|
+
* Directory containing handler files for this spec
|
|
90
|
+
* @default './mocks/{specId}/handlers'
|
|
77
91
|
*/
|
|
78
92
|
handlersDir?: string;
|
|
79
93
|
/**
|
|
80
|
-
* Directory containing seed files
|
|
81
|
-
*
|
|
82
|
-
* Seed files should export an object with schema name keys
|
|
83
|
-
* and seed functions as values. Use `defineSeeds()` for
|
|
84
|
-
* type-safe seed definitions.
|
|
85
|
-
*
|
|
86
|
-
* @example './mocks/seeds'
|
|
87
|
-
* @default './mocks/seeds'
|
|
94
|
+
* Directory containing seed files for this spec
|
|
95
|
+
* @default './mocks/{specId}/seeds'
|
|
88
96
|
*/
|
|
89
97
|
seedsDir?: string;
|
|
90
98
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* When false, the plugin does nothing and Vite runs normally.
|
|
94
|
-
* Useful for conditional enabling based on environment.
|
|
95
|
-
*
|
|
96
|
-
* @default true
|
|
97
|
-
*/
|
|
98
|
-
enabled?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* ID field configuration per schema
|
|
101
|
-
*
|
|
102
|
-
* Maps schema names to the field used as the primary identifier.
|
|
103
|
-
* Used by the store for CRUD operations.
|
|
104
|
-
*
|
|
105
|
-
* @example { User: 'username', Order: 'orderId' }
|
|
99
|
+
* ID field configuration per schema for this spec
|
|
106
100
|
* @default {} (uses 'id' for all schemas)
|
|
107
101
|
*/
|
|
108
102
|
idFields?: Record<string, string>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Plugin configuration options
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* import { openApiServer } from '@websublime/vite-plugin-open-api-server';
|
|
110
|
+
*
|
|
111
|
+
* export default defineConfig({
|
|
112
|
+
* plugins: [
|
|
113
|
+
* openApiServer({
|
|
114
|
+
* specs: [
|
|
115
|
+
* { spec: './openapi/petstore.yaml' },
|
|
116
|
+
* { spec: './openapi/inventory.yaml', id: 'inventory' },
|
|
117
|
+
* ],
|
|
118
|
+
* port: 4000,
|
|
119
|
+
* }),
|
|
120
|
+
* ],
|
|
121
|
+
* });
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
interface OpenApiServerOptions {
|
|
109
125
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
126
|
+
* Array of OpenAPI spec configurations (required)
|
|
127
|
+
* Each entry runs as an isolated instance.
|
|
128
|
+
*/
|
|
129
|
+
specs: SpecConfig[];
|
|
130
|
+
/**
|
|
131
|
+
* Server port — all spec instances share this port
|
|
132
|
+
* @default 4000
|
|
133
|
+
*/
|
|
134
|
+
port?: number;
|
|
135
|
+
/**
|
|
136
|
+
* Enable/disable plugin
|
|
137
|
+
* @default true
|
|
138
|
+
*/
|
|
139
|
+
enabled?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Maximum timeline events per spec
|
|
115
142
|
* @default 500
|
|
116
143
|
*/
|
|
117
144
|
timelineLimit?: number;
|
|
118
145
|
/**
|
|
119
146
|
* Enable DevTools integration
|
|
120
|
-
*
|
|
121
|
-
* When true, mounts the DevTools SPA at `/_devtools`
|
|
122
|
-
* and enables Vue DevTools custom tab.
|
|
123
|
-
*
|
|
124
147
|
* @default true
|
|
125
148
|
*/
|
|
126
149
|
devtools?: boolean;
|
|
127
150
|
/**
|
|
128
|
-
* Enable CORS
|
|
129
|
-
*
|
|
151
|
+
* Enable CORS
|
|
130
152
|
* @default true
|
|
131
153
|
*/
|
|
132
154
|
cors?: boolean;
|
|
133
155
|
/**
|
|
134
156
|
* CORS origin configuration
|
|
135
|
-
*
|
|
136
157
|
* @default '*'
|
|
137
158
|
*/
|
|
138
159
|
corsOrigin?: string | string[];
|
|
139
160
|
/**
|
|
140
161
|
* Custom logger instance
|
|
141
|
-
*
|
|
142
|
-
* Defaults to a Vite-integrated logger that respects
|
|
143
|
-
* Vite's logging level settings.
|
|
144
162
|
*/
|
|
145
163
|
logger?: Logger;
|
|
146
164
|
/**
|
|
147
165
|
* Suppress startup banner
|
|
148
|
-
*
|
|
149
|
-
* When true, the plugin won't print the startup banner
|
|
150
|
-
* showing server details and loaded handlers/seeds.
|
|
151
|
-
*
|
|
152
166
|
* @default false
|
|
153
167
|
*/
|
|
154
168
|
silent?: boolean;
|
|
155
169
|
}
|
|
156
170
|
/**
|
|
157
|
-
* Resolved
|
|
171
|
+
* Resolved spec config with all defaults applied
|
|
158
172
|
*
|
|
159
|
-
*
|
|
173
|
+
* Exported for advanced use cases (e.g., custom orchestrators or
|
|
174
|
+
* test utilities that need to inspect resolved configuration).
|
|
160
175
|
*/
|
|
161
|
-
interface
|
|
176
|
+
interface ResolvedSpecConfig {
|
|
162
177
|
spec: string;
|
|
163
|
-
|
|
178
|
+
/** Guaranteed to be set after orchestrator resolution */
|
|
179
|
+
id: string;
|
|
180
|
+
/** Guaranteed to be set after orchestrator resolution */
|
|
164
181
|
proxyPath: string;
|
|
182
|
+
/**
|
|
183
|
+
* How proxyPath was determined — used for banner display.
|
|
184
|
+
*
|
|
185
|
+
* Set during static option resolution. The orchestrator (Task 1.7)
|
|
186
|
+
* will pass this to the multi-spec banner so it can show
|
|
187
|
+
* "(auto-derived)" vs "(explicit)" next to each proxy path.
|
|
188
|
+
*/
|
|
189
|
+
proxyPathSource: 'auto' | 'explicit';
|
|
165
190
|
handlersDir: string;
|
|
166
191
|
seedsDir: string;
|
|
167
|
-
enabled: boolean;
|
|
168
192
|
idFields: Record<string, string>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Resolved options with defaults applied
|
|
196
|
+
*
|
|
197
|
+
* Exported for advanced use cases (e.g., custom orchestrators or
|
|
198
|
+
* test utilities that need to inspect resolved configuration).
|
|
199
|
+
*/
|
|
200
|
+
interface ResolvedOptions {
|
|
201
|
+
specs: ResolvedSpecConfig[];
|
|
202
|
+
port: number;
|
|
203
|
+
enabled: boolean;
|
|
169
204
|
timelineLimit: number;
|
|
170
205
|
devtools: boolean;
|
|
171
206
|
cors: boolean;
|
|
@@ -482,4 +517,4 @@ declare function registerDevTools(app: App, options?: RegisterDevToolsOptions):
|
|
|
482
517
|
*/
|
|
483
518
|
declare function getDevToolsUrl(port?: number, host?: string, protocol?: 'http' | 'https'): string;
|
|
484
519
|
|
|
485
|
-
export { type FileWatcher, type FileWatcherOptions, type LoadHandlersResult, type LoadSeedsResult, type OpenApiServerOptions, type RegisterDevToolsOptions, type ResolvedOptions, createFileWatcher, debounce, getDevToolsUrl, getHandlerFiles, getSeedFiles, loadHandlers, loadSeeds, openApiServer, registerDevTools };
|
|
520
|
+
export { type FileWatcher, type FileWatcherOptions, type LoadHandlersResult, type LoadSeedsResult, type OpenApiServerOptions, type RegisterDevToolsOptions, type ResolvedOptions, type ResolvedSpecConfig, type SpecConfig, ValidationError, type ValidationErrorCode, createFileWatcher, debounce, getDevToolsUrl, getHandlerFiles, getSeedFiles, loadHandlers, loadSeeds, openApiServer, registerDevTools };
|
package/dist/index.js
CHANGED
|
@@ -68,7 +68,7 @@ function centerText(text, width) {
|
|
|
68
68
|
function extractBannerInfo(registry, document, handlerCount, seedCount, options) {
|
|
69
69
|
return {
|
|
70
70
|
port: options.port,
|
|
71
|
-
proxyPath: options.proxyPath,
|
|
71
|
+
proxyPath: options.specs[0]?.proxyPath || "(pending resolution)",
|
|
72
72
|
title: document.info.title,
|
|
73
73
|
version: document.info.version,
|
|
74
74
|
endpointCount: registry.endpoints.size,
|
|
@@ -409,20 +409,46 @@ async function getSeedFiles(seedsDir, cwd = process.cwd()) {
|
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
// src/types.ts
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
412
|
+
var ValidationError = class extends Error {
|
|
413
|
+
code;
|
|
414
|
+
constructor(code, message) {
|
|
415
|
+
super(message);
|
|
416
|
+
this.name = "ValidationError";
|
|
417
|
+
this.code = code;
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
function validateSpecs(specs) {
|
|
421
|
+
if (!specs || !Array.isArray(specs) || specs.length === 0) {
|
|
422
|
+
throw new ValidationError(
|
|
423
|
+
"SPECS_EMPTY",
|
|
424
|
+
"specs is required and must be a non-empty array of SpecConfig"
|
|
416
425
|
);
|
|
417
426
|
}
|
|
427
|
+
for (let i = 0; i < specs.length; i++) {
|
|
428
|
+
const spec = specs[i];
|
|
429
|
+
if (!spec.spec || typeof spec.spec !== "string" || spec.spec.trim() === "") {
|
|
430
|
+
const identifier = spec.id ? ` (id: "${spec.id}")` : "";
|
|
431
|
+
throw new ValidationError(
|
|
432
|
+
"SPEC_NOT_FOUND",
|
|
433
|
+
`specs[${i}]${identifier}: spec field is required and must be a non-empty string (path or URL to OpenAPI spec)`
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function resolveOptions(options) {
|
|
439
|
+
validateSpecs(options.specs);
|
|
418
440
|
return {
|
|
419
|
-
|
|
441
|
+
specs: options.specs.map((s) => ({
|
|
442
|
+
spec: s.spec,
|
|
443
|
+
id: s.id ?? "",
|
|
444
|
+
proxyPath: s.proxyPath ?? "",
|
|
445
|
+
proxyPathSource: s.proxyPath ? "explicit" : "auto",
|
|
446
|
+
handlersDir: s.handlersDir ?? "",
|
|
447
|
+
seedsDir: s.seedsDir ?? "",
|
|
448
|
+
idFields: s.idFields ?? {}
|
|
449
|
+
})),
|
|
420
450
|
port: options.port ?? 4e3,
|
|
421
|
-
proxyPath: options.proxyPath ?? "/api",
|
|
422
|
-
handlersDir: options.handlersDir ?? "./mocks/handlers",
|
|
423
|
-
seedsDir: options.seedsDir ?? "./mocks/seeds",
|
|
424
451
|
enabled: options.enabled ?? true,
|
|
425
|
-
idFields: options.idFields ?? {},
|
|
426
452
|
timelineLimit: options.timelineLimit ?? 500,
|
|
427
453
|
devtools: options.devtools ?? true,
|
|
428
454
|
cors: options.cors ?? true,
|
|
@@ -539,19 +565,20 @@ try {
|
|
|
539
565
|
);
|
|
540
566
|
}
|
|
541
567
|
}
|
|
568
|
+
const opts = resolvedOptions;
|
|
542
569
|
server = await createOpenApiServer({
|
|
543
|
-
spec:
|
|
544
|
-
port:
|
|
545
|
-
idFields:
|
|
570
|
+
spec: opts.spec,
|
|
571
|
+
port: opts.port,
|
|
572
|
+
idFields: opts.idFields,
|
|
546
573
|
handlers: handlersResult.handlers,
|
|
547
574
|
// Seeds are populated via executeSeeds, not directly
|
|
548
575
|
seeds: /* @__PURE__ */ new Map(),
|
|
549
|
-
timelineLimit:
|
|
550
|
-
devtools:
|
|
576
|
+
timelineLimit: opts.timelineLimit,
|
|
577
|
+
devtools: opts.devtools,
|
|
551
578
|
devtoolsSpaDir,
|
|
552
|
-
cors:
|
|
553
|
-
corsOrigin:
|
|
554
|
-
logger:
|
|
579
|
+
cors: opts.cors,
|
|
580
|
+
corsOrigin: opts.corsOrigin,
|
|
581
|
+
logger: opts.logger
|
|
555
582
|
});
|
|
556
583
|
if (seedsResult.seeds.size > 0) {
|
|
557
584
|
await executeSeeds(seedsResult.seeds, server.store, server.document);
|
|
@@ -636,9 +663,10 @@ try {
|
|
|
636
663
|
if (!server || !vite) return;
|
|
637
664
|
const debouncedHandlerReload = debounce(reloadHandlers, 100);
|
|
638
665
|
const debouncedSeedReload = debounce(reloadSeeds, 100);
|
|
666
|
+
const watchOpts = resolvedOptions;
|
|
639
667
|
fileWatcher = await createFileWatcher({
|
|
640
|
-
handlersDir:
|
|
641
|
-
seedsDir:
|
|
668
|
+
handlersDir: watchOpts.handlersDir,
|
|
669
|
+
seedsDir: watchOpts.seedsDir,
|
|
642
670
|
cwd,
|
|
643
671
|
onHandlerChange: debouncedHandlerReload,
|
|
644
672
|
onSeedChange: debouncedSeedReload
|
|
@@ -647,7 +675,12 @@ try {
|
|
|
647
675
|
async function reloadHandlers() {
|
|
648
676
|
if (!server || !vite) return;
|
|
649
677
|
try {
|
|
650
|
-
const handlersResult = await loadHandlers(
|
|
678
|
+
const handlersResult = await loadHandlers(
|
|
679
|
+
// biome-ignore lint/suspicious/noExplicitAny: v0.x compat — plugin.ts rewritten in Task 1.7
|
|
680
|
+
resolvedOptions.handlersDir,
|
|
681
|
+
vite,
|
|
682
|
+
cwd
|
|
683
|
+
);
|
|
651
684
|
server.updateHandlers(handlersResult.handlers);
|
|
652
685
|
server.wsHub.broadcast({
|
|
653
686
|
type: "handlers:updated",
|
|
@@ -661,7 +694,12 @@ try {
|
|
|
661
694
|
async function reloadSeeds() {
|
|
662
695
|
if (!server || !vite) return;
|
|
663
696
|
try {
|
|
664
|
-
const seedsResult = await loadSeeds(
|
|
697
|
+
const seedsResult = await loadSeeds(
|
|
698
|
+
// biome-ignore lint/suspicious/noExplicitAny: v0.x compat — plugin.ts rewritten in Task 1.7
|
|
699
|
+
resolvedOptions.seedsDir,
|
|
700
|
+
vite,
|
|
701
|
+
cwd
|
|
702
|
+
);
|
|
665
703
|
if (seedsResult.seeds.size > 0) {
|
|
666
704
|
server.store.clearAll();
|
|
667
705
|
await executeSeeds(seedsResult.seeds, server.store, server.document);
|
|
@@ -726,6 +764,6 @@ function getDevToolsUrl(port = 3e3, host, protocol) {
|
|
|
726
764
|
return `${actualProtocol}://${actualHost}:${port}/_devtools/`;
|
|
727
765
|
}
|
|
728
766
|
|
|
729
|
-
export { createFileWatcher, debounce, getDevToolsUrl, getHandlerFiles, getSeedFiles, loadHandlers, loadSeeds, openApiServer, registerDevTools };
|
|
767
|
+
export { ValidationError, createFileWatcher, debounce, getDevToolsUrl, getHandlerFiles, getSeedFiles, loadHandlers, loadSeeds, openApiServer, registerDevTools };
|
|
730
768
|
//# sourceMappingURL=index.js.map
|
|
731
769
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/banner.ts","../src/utils.ts","../src/handlers.ts","../src/hot-reload.ts","../src/seeds.ts","../src/types.ts","../src/plugin.ts","../src/devtools.ts"],"names":["path","fg","require","vite"],"mappings":";;;;;;;;;;AA0CO,SAAS,WAAA,CAAY,MAAkB,OAAA,EAAgC;AAC5E,EAAA,IAAI,QAAQ,MAAA,EAAQ;AAClB,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,IAAU,OAAA;AACjC,EAAA,MAAM,GAAA,GAAM,CAAC,GAAA,KAAgB,MAAA,CAAO,KAAK,GAAG,CAAA;AAG5C,EAAA,MAAM,GAAA,GAAM;AAAA,IACV,OAAA,EAAS,QAAA;AAAA,IACT,QAAA,EAAU,QAAA;AAAA,IACV,UAAA,EAAY,QAAA;AAAA,IACZ,WAAA,EAAa,QAAA;AAAA,IACb,UAAA,EAAY,QAAA;AAAA,IACZ,QAAA,EAAU;AAAA,GACZ;AAEA,EAAA,MAAM,KAAA,GAAQ,EAAA;AACd,EAAA,MAAM,cAAA,GAAiB,GAAA,CAAI,UAAA,CAAW,MAAA,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MAAA,CAAO,SAAS,QAAA,GAAW,WAAA,CAAA;AAEtE,EAAA,OAAO,CAAA,EAAG,cAAc,CAAA,GAAA,EAAM,UAAU,IAAI,IAAI,CAAA,WAAA,CAAA;AAClD","file":"index.js","sourcesContent":["/**\n * Startup Banner\n *\n * What: Prints a colorful startup banner with server information\n * How: Uses picocolors for ANSI color output\n * Why: Provides clear feedback about server status and configuration\n *\n * @module banner\n */\n\nimport type { EndpointRegistry } from '@websublime/vite-plugin-open-api-core';\nimport pc from 'picocolors';\nimport type { ResolvedOptions } from './types.js';\n\n/**\n * Banner configuration\n */\nexport interface BannerInfo {\n /** Server port */\n port: number;\n /** Proxy path in Vite */\n proxyPath: string;\n /** OpenAPI spec title */\n title: string;\n /** OpenAPI spec version */\n version: string;\n /** Number of endpoints */\n endpointCount: number;\n /** Number of loaded handlers */\n handlerCount: number;\n /** Number of loaded seeds */\n seedCount: number;\n /** DevTools enabled */\n devtools: boolean;\n}\n\n/**\n * Print the startup banner\n *\n * @param info - Banner information\n * @param options - Resolved plugin options\n */\nexport function printBanner(info: BannerInfo, options: ResolvedOptions): void {\n if (options.silent) {\n return;\n }\n\n const logger = options.logger ?? console;\n const log = (msg: string) => logger.info(msg);\n\n // Box drawing characters\n const BOX = {\n topLeft: '╭',\n topRight: '╮',\n bottomLeft: '╰',\n bottomRight: '╯',\n horizontal: '─',\n vertical: '│',\n };\n\n const width = 56;\n const horizontalLine = BOX.horizontal.repeat(width - 2);\n\n log('');\n log(pc.cyan(`${BOX.topLeft}${horizontalLine}${BOX.topRight}`));\n log(\n pc.cyan(BOX.vertical) + centerText('🚀 OpenAPI Mock Server', width - 2) + pc.cyan(BOX.vertical),\n );\n log(pc.cyan(`${BOX.bottomLeft}${horizontalLine}${BOX.bottomRight}`));\n log('');\n\n // API Info\n log(\n ` ${pc.bold(pc.white('API:'))} ${pc.green(info.title)} ${pc.dim(`v${info.version}`)}`,\n );\n log(` ${pc.bold(pc.white('Server:'))} ${pc.cyan(`http://localhost:${info.port}`)}`);\n log(\n ` ${pc.bold(pc.white('Proxy:'))} ${pc.yellow(info.proxyPath)} ${pc.dim('→')} ${pc.dim(`localhost:${info.port}`)}`,\n );\n log('');\n\n // Stats\n const stats = [\n { label: 'Endpoints', value: info.endpointCount, color: pc.blue },\n { label: 'Handlers', value: info.handlerCount, color: pc.green },\n { label: 'Seeds', value: info.seedCount, color: pc.magenta },\n ];\n\n const statsLine = stats\n .map((s) => `${pc.dim(`${s.label}:`)} ${s.color(String(s.value))}`)\n .join(pc.dim(' │ '));\n log(` ${statsLine}`);\n log('');\n\n // DevTools\n if (info.devtools) {\n log(\n ` ${pc.bold(pc.white('DevTools:'))} ${pc.cyan(`http://localhost:${info.port}/_devtools`)}`,\n );\n log(` ${pc.bold(pc.white('API Info:'))} ${pc.cyan(`http://localhost:${info.port}/_api`)}`);\n log('');\n }\n\n // Footer\n log(pc.dim(' Press Ctrl+C to stop the server'));\n log('');\n}\n\n/**\n * Center text within a given width\n *\n * @param text - Text to center\n * @param width - Total width\n * @returns Centered text with padding\n */\n// biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape codes require control characters\nconst ANSI_ESCAPE_REGEX = /\\x1b\\[[0-9;]*m/g;\n\nfunction centerText(text: string, width: number): string {\n // Account for ANSI codes - get visible length\n const visibleLength = text.replace(ANSI_ESCAPE_REGEX, '').length;\n const padding = Math.max(0, width - visibleLength);\n const leftPad = Math.floor(padding / 2);\n const rightPad = padding - leftPad;\n return ' '.repeat(leftPad) + text + ' '.repeat(rightPad);\n}\n\n/**\n * Extract banner info from server registry and document\n *\n * @param registry - Endpoint registry\n * @param document - OpenAPI document\n * @param handlerCount - Number of loaded handlers\n * @param seedCount - Number of loaded seed schemas\n * @param options - Resolved options\n * @returns Banner info\n */\nexport function extractBannerInfo(\n registry: EndpointRegistry,\n document: { info: { title: string; version: string } },\n handlerCount: number,\n seedCount: number,\n options: ResolvedOptions,\n): BannerInfo {\n return {\n port: options.port,\n proxyPath: options.proxyPath,\n title: document.info.title,\n version: document.info.version,\n endpointCount: registry.endpoints.size,\n handlerCount,\n seedCount,\n devtools: options.devtools,\n };\n}\n\n/**\n * Print a hot reload notification\n *\n * @param type - Type of reload ('handlers' | 'seeds')\n * @param count - Number of reloaded items\n * @param options - Resolved options\n */\nexport function printReloadNotification(\n type: 'handlers' | 'seeds',\n count: number,\n options: ResolvedOptions,\n): void {\n if (options.silent) {\n return;\n }\n\n const logger = options.logger ?? console;\n const icon = type === 'handlers' ? '🔄' : '🌱';\n const label = type === 'handlers' ? 'Handlers' : 'Seeds';\n const color = type === 'handlers' ? pc.green : pc.magenta;\n\n logger.info(` ${icon} ${color(label)} reloaded: ${pc.bold(String(count))} ${type}`);\n}\n\n/**\n * Print an error message\n *\n * @param message - Error message\n * @param error - Optional error object\n * @param options - Resolved options\n */\nexport function printError(message: string, error: unknown, options: ResolvedOptions): void {\n const logger = options.logger ?? console;\n logger.error(`${pc.red('✖')} ${pc.bold(pc.red('Error:'))} ${message}`);\n if (error instanceof Error) {\n logger.error(pc.dim(` ${error.message}`));\n }\n}\n\n/**\n * Print a warning message\n *\n * @param message - Warning message\n * @param options - Resolved options\n */\nexport function printWarning(message: string, options: ResolvedOptions): void {\n if (options.silent) {\n return;\n }\n\n const logger = options.logger ?? console;\n logger.warn(`${pc.yellow('⚠')} ${pc.yellow('Warning:')} ${message}`);\n}\n","/**\n * Filesystem Utilities\n *\n * What: Shared utility functions for filesystem operations\n * How: Uses Node.js fs/promises module with error handling\n * Why: Provides reusable utilities for handler and seed loading\n *\n * @module utils\n */\n\n/**\n * Check if a directory exists\n *\n * @param dirPath - Path to check\n * @returns Promise resolving to true if directory exists\n */\nexport async function directoryExists(dirPath: string): Promise<boolean> {\n try {\n const fs = await import('node:fs/promises');\n const stats = await fs.stat(dirPath);\n return stats.isDirectory();\n } catch {\n return false;\n }\n}\n","/**\n * Handler Loading\n *\n * What: Loads handler files from a directory using glob patterns\n * How: Uses Vite's ssrLoadModule to transform and load TypeScript files\n * Why: Enables users to define custom handlers for operationIds in TypeScript\n *\n * @module handlers\n */\n\nimport path from 'node:path';\nimport type { HandlerDefinition, HandlerFn, Logger } from '@websublime/vite-plugin-open-api-core';\nimport fg from 'fast-glob';\nimport type { ViteDevServer } from 'vite';\nimport { directoryExists } from './utils.js';\n\n/**\n * Result of loading handlers\n */\nexport interface LoadHandlersResult {\n /** Map of operationId to handler function */\n handlers: Map<string, HandlerFn>;\n /** Number of handler files loaded */\n fileCount: number;\n /** List of loaded file paths (relative) */\n files: string[];\n}\n\n/**\n * Load handlers from a directory\n *\n * Searches for handler files matching the pattern `*.handlers.{ts,js,mjs}`\n * in the specified directory. Each file should export an object with\n * operationId keys and handler functions as values.\n *\n * Uses Vite's ssrLoadModule to transform TypeScript files on-the-fly.\n *\n * @example\n * ```typescript\n * // mocks/handlers/pets.handlers.ts\n * import { defineHandlers } from '@websublime/vite-plugin-open-api-core';\n *\n * export default defineHandlers({\n * getPetById: async ({ req, store }) => {\n * const pet = store.get('Pet', req.params.petId);\n * return pet ?? { status: 404, data: { message: 'Pet not found' } };\n * },\n * });\n * ```\n *\n * @param handlersDir - Directory to search for handler files\n * @param viteServer - Vite dev server instance for ssrLoadModule\n * @param cwd - Current working directory (defaults to process.cwd())\n * @param logger - Optional logger for warnings/errors\n * @returns Promise resolving to loaded handlers\n */\nexport async function loadHandlers(\n handlersDir: string,\n viteServer: ViteDevServer,\n cwd: string = process.cwd(),\n logger: Logger = console,\n): Promise<LoadHandlersResult> {\n const handlers = new Map<string, HandlerFn>();\n const absoluteDir = path.resolve(cwd, handlersDir);\n\n // Check if directory exists\n const dirExists = await directoryExists(absoluteDir);\n if (!dirExists) {\n return {\n handlers,\n fileCount: 0,\n files: [],\n };\n }\n\n // Find handler files (supports TypeScript via Vite's transform)\n const pattern = '**/*.handlers.{ts,js,mjs}';\n const files = await fg(pattern, {\n cwd: absoluteDir,\n absolute: false,\n onlyFiles: true,\n ignore: ['node_modules/**', 'dist/**'],\n });\n\n // Load each file using Vite's ssrLoadModule\n for (const file of files) {\n const absolutePath = path.join(absoluteDir, file);\n const fileHandlers = await loadHandlerFile(absolutePath, viteServer, logger);\n\n // Merge handlers\n for (const [operationId, handler] of Object.entries(fileHandlers)) {\n if (handlers.has(operationId)) {\n logger.warn(\n `[vite-plugin-open-api-server] Duplicate handler for operationId \"${operationId}\" in ${file}. Using last definition.`,\n );\n }\n handlers.set(operationId, handler);\n }\n }\n\n return {\n handlers,\n fileCount: files.length,\n files,\n };\n}\n\n/**\n * Load a single handler file using Vite's ssrLoadModule\n *\n * @param filePath - Absolute path to the handler file\n * @param viteServer - Vite dev server instance\n * @param logger - Logger for warnings/errors\n * @returns Promise resolving to handler definition object\n */\nasync function loadHandlerFile(\n filePath: string,\n viteServer: ViteDevServer,\n logger: Logger,\n): Promise<HandlerDefinition> {\n try {\n // Invalidate module cache for hot reload\n const moduleNode = viteServer.moduleGraph.getModuleById(filePath);\n if (moduleNode) {\n viteServer.moduleGraph.invalidateModule(moduleNode);\n }\n\n // Use Vite's ssrLoadModule to transform and load the file\n // This handles TypeScript, ESM, and other transforms automatically\n const module = await viteServer.ssrLoadModule(filePath);\n\n // Support both default export and named export\n const handlers = module.default ?? module.handlers ?? module;\n\n // Validate handlers object\n if (!handlers || typeof handlers !== 'object') {\n logger.warn(\n `[vite-plugin-open-api-server] Invalid handler file ${filePath}: expected object export`,\n );\n return {};\n }\n\n // Filter to only handler functions\n const validHandlers: HandlerDefinition = {};\n for (const [key, value] of Object.entries(handlers)) {\n if (typeof value === 'function') {\n validHandlers[key] = value as HandlerFn;\n }\n }\n\n return validHandlers;\n } catch (error) {\n logger.error(\n `[vite-plugin-open-api-server] Failed to load handler file ${filePath}:`,\n error instanceof Error ? error.message : error,\n );\n return {};\n }\n}\n\n/**\n * Get list of handler files in a directory\n *\n * Useful for file watching setup.\n *\n * @param handlersDir - Directory to search\n * @param cwd - Current working directory\n * @returns Promise resolving to list of absolute file paths\n */\nexport async function getHandlerFiles(\n handlersDir: string,\n cwd: string = process.cwd(),\n): Promise<string[]> {\n const absoluteDir = path.resolve(cwd, handlersDir);\n\n const dirExists = await directoryExists(absoluteDir);\n if (!dirExists) {\n return [];\n }\n\n const pattern = '**/*.handlers.{ts,js,mjs}';\n const files = await fg(pattern, {\n cwd: absoluteDir,\n absolute: true,\n onlyFiles: true,\n ignore: ['node_modules/**', 'dist/**'],\n });\n\n return files;\n}\n","/**\n * Hot Reload\n *\n * What: File watcher for hot reloading handlers and seeds\n * How: Uses chokidar to watch for file changes\n * Why: Enables rapid development iteration without server restart\n *\n * @module hot-reload\n *\n * TODO: Full implementation in Task 3.3\n * This module provides placeholder/basic functionality for Task 3.1\n */\n\nimport path from 'node:path';\nimport type { Logger } from '@websublime/vite-plugin-open-api-core';\nimport type { FSWatcher } from 'chokidar';\n\n/**\n * File watcher configuration\n */\nexport interface FileWatcherOptions {\n /** Directory containing handler files */\n handlersDir?: string;\n /** Directory containing seed files */\n seedsDir?: string;\n /** Callback when a handler file changes */\n onHandlerChange?: (filePath: string) => Promise<void> | void;\n /** Callback when a seed file changes */\n onSeedChange?: (filePath: string) => Promise<void> | void;\n /** Current working directory */\n cwd?: string;\n /** Logger for error messages */\n logger?: Logger;\n}\n\n/**\n * File watcher instance\n */\nexport interface FileWatcher {\n /** Close the watcher and release resources */\n close(): Promise<void>;\n /** Check if watcher is active */\n readonly isWatching: boolean;\n /** Promise that resolves when all watchers are ready */\n readonly ready: Promise<void>;\n}\n\n/**\n * Create a file watcher for handlers and seeds\n *\n * Watches for changes to handler and seed files and invokes\n * callbacks when changes are detected. Supports add, change,\n * and unlink events.\n *\n * @example\n * ```typescript\n * const watcher = await createFileWatcher({\n * handlersDir: './mocks/handlers',\n * seedsDir: './mocks/seeds',\n * onHandlerChange: async (file) => {\n * console.log('Handler changed:', file);\n * const handlers = await loadHandlers('./mocks/handlers');\n * server.updateHandlers(handlers.handlers);\n * },\n * onSeedChange: async (file) => {\n * console.log('Seed changed:', file);\n * const seeds = await loadSeeds('./mocks/seeds');\n * // Re-execute seeds...\n * },\n * });\n *\n * // Later, clean up\n * await watcher.close();\n * ```\n *\n * @param options - Watcher configuration\n * @returns Promise resolving to file watcher instance\n */\nexport async function createFileWatcher(options: FileWatcherOptions): Promise<FileWatcher> {\n const {\n handlersDir,\n seedsDir,\n onHandlerChange,\n onSeedChange,\n cwd = process.cwd(),\n logger = console,\n } = options;\n\n // Dynamic import chokidar to avoid bundling issues\n const { watch } = await import('chokidar');\n\n const watchers: FSWatcher[] = [];\n const readyPromises: Promise<void>[] = [];\n let isWatching = true;\n\n // Handler file patterns\n const handlerPattern = '**/*.handlers.{ts,js,mjs}';\n const seedPattern = '**/*.seeds.{ts,js,mjs}';\n\n /**\n * Wrapper to safely invoke async callbacks and log errors\n * Prevents unhandled promise rejections from file watcher events\n */\n const safeInvoke = (\n callback: (filePath: string) => Promise<void> | void,\n filePath: string,\n context: string,\n ): void => {\n Promise.resolve()\n .then(() => callback(filePath))\n .catch((error) => {\n logger.error(\n `[vite-plugin-open-api-server] ${context} callback error for ${filePath}:`,\n error,\n );\n });\n };\n\n // Watch handlers directory\n if (handlersDir && onHandlerChange) {\n const absoluteHandlersDir = path.resolve(cwd, handlersDir);\n const handlerWatcher = watch(handlerPattern, {\n cwd: absoluteHandlersDir,\n ignoreInitial: true,\n ignored: ['**/node_modules/**', '**/dist/**'],\n persistent: true,\n awaitWriteFinish: {\n stabilityThreshold: 100,\n pollInterval: 50,\n },\n });\n\n handlerWatcher.on('add', (file) => {\n const absolutePath = path.join(absoluteHandlersDir, file);\n safeInvoke(onHandlerChange, absolutePath, 'Handler add');\n });\n\n handlerWatcher.on('change', (file) => {\n const absolutePath = path.join(absoluteHandlersDir, file);\n safeInvoke(onHandlerChange, absolutePath, 'Handler change');\n });\n\n handlerWatcher.on('unlink', (file) => {\n const absolutePath = path.join(absoluteHandlersDir, file);\n safeInvoke(onHandlerChange, absolutePath, 'Handler unlink');\n });\n\n handlerWatcher.on('error', (error) => {\n logger.error('[vite-plugin-open-api-server] Handler watcher error:', error);\n });\n\n // Track ready promise for this watcher\n readyPromises.push(\n new Promise<void>((resolve) => {\n handlerWatcher.on('ready', () => resolve());\n }),\n );\n\n watchers.push(handlerWatcher);\n }\n\n // Watch seeds directory\n if (seedsDir && onSeedChange) {\n const absoluteSeedsDir = path.resolve(cwd, seedsDir);\n const seedWatcher = watch(seedPattern, {\n cwd: absoluteSeedsDir,\n ignoreInitial: true,\n ignored: ['**/node_modules/**', '**/dist/**'],\n persistent: true,\n awaitWriteFinish: {\n stabilityThreshold: 100,\n pollInterval: 50,\n },\n });\n\n seedWatcher.on('add', (file) => {\n const absolutePath = path.join(absoluteSeedsDir, file);\n safeInvoke(onSeedChange, absolutePath, 'Seed add');\n });\n\n seedWatcher.on('change', (file) => {\n const absolutePath = path.join(absoluteSeedsDir, file);\n safeInvoke(onSeedChange, absolutePath, 'Seed change');\n });\n\n seedWatcher.on('unlink', (file) => {\n const absolutePath = path.join(absoluteSeedsDir, file);\n safeInvoke(onSeedChange, absolutePath, 'Seed unlink');\n });\n\n seedWatcher.on('error', (error) => {\n logger.error('[vite-plugin-open-api-server] Seed watcher error:', error);\n });\n\n // Track ready promise for this watcher\n readyPromises.push(\n new Promise<void>((resolve) => {\n seedWatcher.on('ready', () => resolve());\n }),\n );\n\n watchers.push(seedWatcher);\n }\n\n // Create combined ready promise\n const readyPromise = Promise.all(readyPromises).then(() => {});\n\n return {\n async close(): Promise<void> {\n isWatching = false;\n await Promise.all(watchers.map((w) => w.close()));\n },\n get isWatching(): boolean {\n return isWatching;\n },\n get ready(): Promise<void> {\n return readyPromise;\n },\n };\n}\n\n/**\n * Debounce a function with async execution guard\n *\n * Useful for preventing multiple rapid reloads when\n * multiple files change at once (e.g., during save all).\n *\n * This implementation prevents overlapping async executions:\n * - If the function is already running, the call is queued\n * - When the running function completes, it executes with the latest args\n * - Multiple calls during execution are coalesced into one\n *\n * @param fn - Function to debounce (can be sync or async)\n * @param delay - Debounce delay in milliseconds\n * @returns Debounced function\n */\nexport function debounce<T extends (...args: unknown[]) => unknown>(\n fn: T,\n delay: number,\n): (...args: Parameters<T>) => void {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n let isRunning = false;\n let pendingArgs: Parameters<T> | null = null;\n\n const execute = async (...args: Parameters<T>): Promise<void> => {\n if (isRunning) {\n // Queue the latest args for execution after current run completes\n pendingArgs = args;\n return;\n }\n\n isRunning = true;\n try {\n // Wrap in try-catch to handle sync throws, then await for async rejections\n // This prevents both sync errors and async rejections from propagating\n try {\n await fn(...args);\n } catch {\n // Silently catch errors - the caller is responsible for error handling\n // This prevents unhandled rejections from breaking the debounce chain\n }\n } finally {\n isRunning = false;\n\n // If there were calls during execution, run with the latest args\n if (pendingArgs !== null) {\n const nextArgs = pendingArgs;\n pendingArgs = null;\n // Use setTimeout to avoid deep recursion\n setTimeout(() => execute(...nextArgs), 0);\n }\n }\n };\n\n return (...args: Parameters<T>): void => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n timeoutId = setTimeout(() => {\n timeoutId = null;\n execute(...args);\n }, delay);\n };\n}\n","/**\n * Seed Loading\n *\n * What: Loads seed files from a directory using glob patterns\n * How: Uses Vite's ssrLoadModule to transform and load TypeScript files\n * Why: Enables users to define seed data for schemas in TypeScript\n *\n * @module seeds\n */\n\nimport path from 'node:path';\nimport type { AnySeedFn, Logger, SeedDefinition } from '@websublime/vite-plugin-open-api-core';\nimport fg from 'fast-glob';\nimport type { ViteDevServer } from 'vite';\nimport { directoryExists } from './utils.js';\n\n/**\n * Result of loading seeds\n */\nexport interface LoadSeedsResult {\n /** Map of schema name to seed function */\n seeds: Map<string, AnySeedFn>;\n /** Number of seed files loaded */\n fileCount: number;\n /** List of loaded file paths (relative) */\n files: string[];\n}\n\n/**\n * Load seeds from a directory\n *\n * Searches for seed files matching the pattern `*.seeds.{ts,js,mjs}`\n * in the specified directory. Each file should export an object with\n * schema name keys and seed functions as values.\n *\n * Uses Vite's ssrLoadModule to transform TypeScript files on-the-fly.\n *\n * @example\n * ```typescript\n * // mocks/seeds/pets.seeds.ts\n * import { defineSeeds } from '@websublime/vite-plugin-open-api-core';\n *\n * export default defineSeeds({\n * Pet: ({ seed, faker }) => {\n * return seed.count(10, () => ({\n * id: faker.number.int({ min: 1, max: 1000 }),\n * name: faker.animal.dog(),\n * status: faker.helpers.arrayElement(['available', 'pending', 'sold']),\n * }));\n * },\n * });\n * ```\n *\n * @param seedsDir - Directory to search for seed files\n * @param viteServer - Vite dev server instance for ssrLoadModule\n * @param cwd - Current working directory (defaults to process.cwd())\n * @param logger - Optional logger for warnings/errors\n * @returns Promise resolving to loaded seeds\n */\nexport async function loadSeeds(\n seedsDir: string,\n viteServer: ViteDevServer,\n cwd: string = process.cwd(),\n logger: Logger = console,\n): Promise<LoadSeedsResult> {\n const seeds = new Map<string, AnySeedFn>();\n const absoluteDir = path.resolve(cwd, seedsDir);\n\n // Check if directory exists\n const dirExists = await directoryExists(absoluteDir);\n if (!dirExists) {\n return {\n seeds,\n fileCount: 0,\n files: [],\n };\n }\n\n // Find seed files (supports TypeScript via Vite's transform)\n const pattern = '**/*.seeds.{ts,js,mjs}';\n const files = await fg(pattern, {\n cwd: absoluteDir,\n absolute: false,\n onlyFiles: true,\n ignore: ['node_modules/**', 'dist/**'],\n });\n\n // Load each file using Vite's ssrLoadModule\n for (const file of files) {\n const absolutePath = path.join(absoluteDir, file);\n const fileSeeds = await loadSeedFile(absolutePath, viteServer, logger);\n\n // Merge seeds\n for (const [schemaName, seedFn] of Object.entries(fileSeeds)) {\n if (seeds.has(schemaName)) {\n logger.warn(\n `[vite-plugin-open-api-server] Duplicate seed for schema \"${schemaName}\" in ${file}. Using last definition.`,\n );\n }\n seeds.set(schemaName, seedFn);\n }\n }\n\n return {\n seeds,\n fileCount: files.length,\n files,\n };\n}\n\n/**\n * Load a single seed file using Vite's ssrLoadModule\n *\n * @param filePath - Absolute path to the seed file\n * @param viteServer - Vite dev server instance\n * @param logger - Logger for warnings/errors\n * @returns Promise resolving to seed definition object\n */\nasync function loadSeedFile(\n filePath: string,\n viteServer: ViteDevServer,\n logger: Logger,\n): Promise<SeedDefinition> {\n try {\n // Invalidate module cache for hot reload\n const moduleNode = viteServer.moduleGraph.getModuleById(filePath);\n if (moduleNode) {\n viteServer.moduleGraph.invalidateModule(moduleNode);\n }\n\n // Use Vite's ssrLoadModule to transform and load the file\n // This handles TypeScript, ESM, and other transforms automatically\n const module = await viteServer.ssrLoadModule(filePath);\n\n // Support both default export and named export\n const seeds = module.default ?? module.seeds ?? module;\n\n // Validate seeds object\n if (!seeds || typeof seeds !== 'object') {\n logger.warn(\n `[vite-plugin-open-api-server] Invalid seed file ${filePath}: expected object export`,\n );\n return {};\n }\n\n // Filter to only seed functions\n const validSeeds: SeedDefinition = {};\n for (const [key, value] of Object.entries(seeds)) {\n if (typeof value === 'function') {\n validSeeds[key] = value as AnySeedFn;\n }\n }\n\n return validSeeds;\n } catch (error) {\n logger.error(\n `[vite-plugin-open-api-server] Failed to load seed file ${filePath}:`,\n error instanceof Error ? error.message : error,\n );\n return {};\n }\n}\n\n/**\n * Get list of seed files in a directory\n *\n * Useful for file watching setup.\n *\n * @param seedsDir - Directory to search\n * @param cwd - Current working directory\n * @returns Promise resolving to list of absolute file paths\n */\nexport async function getSeedFiles(\n seedsDir: string,\n cwd: string = process.cwd(),\n): Promise<string[]> {\n const absoluteDir = path.resolve(cwd, seedsDir);\n\n const dirExists = await directoryExists(absoluteDir);\n if (!dirExists) {\n return [];\n }\n\n const pattern = '**/*.seeds.{ts,js,mjs}';\n const files = await fg(pattern, {\n cwd: absoluteDir,\n absolute: true,\n onlyFiles: true,\n ignore: ['node_modules/**', 'dist/**'],\n });\n\n return files;\n}\n","/**\n * Vite Plugin Types\n *\n * What: Type definitions for the OpenAPI server Vite plugin\n * How: Defines configuration options and internal types\n * Why: Provides type safety and documentation for plugin consumers\n *\n * @module types\n */\n\nimport type { Logger } from '@websublime/vite-plugin-open-api-core';\n\n/**\n * Plugin configuration options\n *\n * @example\n * ```typescript\n * import { openApiServer } from '@websublime/vite-plugin-open-api-server';\n *\n * export default defineConfig({\n * plugins: [\n * openApiServer({\n * spec: './openapi/petstore.yaml',\n * port: 4000,\n * proxyPath: '/api',\n * handlersDir: './mocks/handlers',\n * seedsDir: './mocks/seeds',\n * }),\n * ],\n * });\n * ```\n */\nexport interface OpenApiServerOptions {\n /**\n * Path to OpenAPI spec file (required)\n *\n * Supports:\n * - Local file paths (relative or absolute)\n * - URLs (http:// or https://)\n * - YAML or JSON format\n *\n * @example './openapi/petstore.yaml'\n * @example 'https://petstore3.swagger.io/api/v3/openapi.json'\n */\n spec: string;\n\n /**\n * Server port for the mock server\n *\n * The mock server runs on this port, and Vite proxies\n * requests from `proxyPath` to this server.\n *\n * @default 4000\n */\n port?: number;\n\n /**\n * Base path for request proxy\n *\n * All requests to this path in your Vite dev server\n * will be proxied to the mock server.\n *\n * @example '/api/v3'\n * @default '/api'\n */\n proxyPath?: string;\n\n /**\n * Directory containing handler files\n *\n * Handler files should export an object with operationId keys\n * and handler functions as values. Use `defineHandlers()` for\n * type-safe handler definitions.\n *\n * @example './mocks/handlers'\n * @default './mocks/handlers'\n */\n handlersDir?: string;\n\n /**\n * Directory containing seed files\n *\n * Seed files should export an object with schema name keys\n * and seed functions as values. Use `defineSeeds()` for\n * type-safe seed definitions.\n *\n * @example './mocks/seeds'\n * @default './mocks/seeds'\n */\n seedsDir?: string;\n\n /**\n * Enable/disable the plugin\n *\n * When false, the plugin does nothing and Vite runs normally.\n * Useful for conditional enabling based on environment.\n *\n * @default true\n */\n enabled?: boolean;\n\n /**\n * ID field configuration per schema\n *\n * Maps schema names to the field used as the primary identifier.\n * Used by the store for CRUD operations.\n *\n * @example { User: 'username', Order: 'orderId' }\n * @default {} (uses 'id' for all schemas)\n */\n idFields?: Record<string, string>;\n\n /**\n * Maximum timeline events to keep\n *\n * The timeline stores request/response history for DevTools.\n * Older events are removed when this limit is exceeded.\n *\n * @default 500\n */\n timelineLimit?: number;\n\n /**\n * Enable DevTools integration\n *\n * When true, mounts the DevTools SPA at `/_devtools`\n * and enables Vue DevTools custom tab.\n *\n * @default true\n */\n devtools?: boolean;\n\n /**\n * Enable CORS on the mock server\n *\n * @default true\n */\n cors?: boolean;\n\n /**\n * CORS origin configuration\n *\n * @default '*'\n */\n corsOrigin?: string | string[];\n\n /**\n * Custom logger instance\n *\n * Defaults to a Vite-integrated logger that respects\n * Vite's logging level settings.\n */\n logger?: Logger;\n\n /**\n * Suppress startup banner\n *\n * When true, the plugin won't print the startup banner\n * showing server details and loaded handlers/seeds.\n *\n * @default false\n */\n silent?: boolean;\n}\n\n/**\n * Resolved plugin options with defaults applied\n *\n * @internal\n */\nexport interface ResolvedOptions {\n spec: string;\n port: number;\n proxyPath: string;\n handlersDir: string;\n seedsDir: string;\n enabled: boolean;\n idFields: Record<string, string>;\n timelineLimit: number;\n devtools: boolean;\n cors: boolean;\n corsOrigin: string | string[];\n silent: boolean;\n logger?: Logger;\n}\n\n/**\n * Resolve options with defaults\n *\n * @param options - User-provided options\n * @returns Resolved options with all defaults applied\n */\nexport function resolveOptions(options: OpenApiServerOptions): ResolvedOptions {\n // Validate required spec option\n if (!options.spec || typeof options.spec !== 'string' || options.spec.trim() === '') {\n throw new Error(\n 'spec is required and must be a non-empty string (path or URL to OpenAPI spec)',\n );\n }\n\n return {\n spec: options.spec,\n port: options.port ?? 4000,\n proxyPath: options.proxyPath ?? '/api',\n handlersDir: options.handlersDir ?? './mocks/handlers',\n seedsDir: options.seedsDir ?? './mocks/seeds',\n enabled: options.enabled ?? true,\n idFields: options.idFields ?? {},\n timelineLimit: options.timelineLimit ?? 500,\n devtools: options.devtools ?? true,\n cors: options.cors ?? true,\n corsOrigin: options.corsOrigin ?? '*',\n silent: options.silent ?? false,\n logger: options.logger,\n };\n}\n","/**\n * Vite Plugin Implementation\n *\n * What: Main Vite plugin for OpenAPI mock server\n * How: Uses configureServer hook to start mock server and configure proxy\n * Why: Integrates OpenAPI mock server seamlessly into Vite dev workflow\n *\n * @module plugin\n */\n\nimport { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n createOpenApiServer,\n executeSeeds,\n type OpenApiServer,\n} from '@websublime/vite-plugin-open-api-core';\nimport type { Plugin, ViteDevServer } from 'vite';\nimport { extractBannerInfo, printBanner, printError, printReloadNotification } from './banner.js';\nimport { loadHandlers } from './handlers.js';\nimport { createFileWatcher, debounce, type FileWatcher } from './hot-reload.js';\nimport { loadSeeds } from './seeds.js';\nimport { type OpenApiServerOptions, resolveOptions } from './types.js';\n\n/**\n * Create the OpenAPI Server Vite plugin\n *\n * This plugin starts a mock server based on an OpenAPI specification\n * and configures Vite to proxy API requests to it.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import vue from '@vitejs/plugin-vue';\n * import { openApiServer } from '@websublime/vite-plugin-open-api-server';\n *\n * export default defineConfig({\n * plugins: [\n * vue(),\n * openApiServer({\n * spec: './openapi/petstore.yaml',\n * port: 4000,\n * proxyPath: '/api',\n * handlersDir: './mocks/handlers',\n * seedsDir: './mocks/seeds',\n * }),\n * ],\n * });\n * ```\n *\n * @param options - Plugin configuration options\n * @returns Vite plugin\n */\n/**\n * Virtual module ID for the DevTools tab registration script.\n *\n * This script is served as a Vite module (not inline HTML) so that bare\n * import specifiers like `@vue/devtools-api` are resolved through Vite's\n * module pipeline. Inline `<script type=\"module\">` blocks in HTML are\n * executed directly by the browser, which cannot resolve bare specifiers.\n */\nconst VIRTUAL_DEVTOOLS_TAB_ID = 'virtual:open-api-devtools-tab';\nconst RESOLVED_VIRTUAL_DEVTOOLS_TAB_ID = `\\0${VIRTUAL_DEVTOOLS_TAB_ID}`;\n\nexport function openApiServer(options: OpenApiServerOptions): Plugin {\n const resolvedOptions = resolveOptions(options);\n\n // Server instance (created in configureServer)\n let server: OpenApiServer | null = null;\n\n // Vite dev server reference (needed for ssrLoadModule)\n let vite: ViteDevServer | null = null;\n\n // File watcher for hot reload\n let fileWatcher: FileWatcher | null = null;\n\n // Current working directory (set in configureServer)\n let cwd: string = process.cwd();\n\n return {\n name: 'vite-plugin-open-api-server',\n\n // Only active in dev mode\n apply: 'serve',\n\n /**\n * Ensure @vue/devtools-api is available for the DevTools tab module\n *\n * The virtual module imports from '@vue/devtools-api', which Vite needs\n * to pre-bundle so it can be resolved at runtime in the browser, even\n * though the host app may not have it as a direct dependency.\n */\n config() {\n if (!resolvedOptions.devtools || !resolvedOptions.enabled) {\n return;\n }\n\n // Only add to optimizeDeps if the package is actually resolvable\n // to avoid Vite warnings when the consumer hasn't installed it\n const require = createRequire(import.meta.url);\n try {\n require.resolve('@vue/devtools-api');\n } catch {\n return;\n }\n\n return {\n optimizeDeps: {\n include: ['@vue/devtools-api'],\n },\n };\n },\n\n /**\n * Resolve the virtual module for DevTools tab registration\n */\n resolveId(id: string) {\n if (id === VIRTUAL_DEVTOOLS_TAB_ID) {\n return RESOLVED_VIRTUAL_DEVTOOLS_TAB_ID;\n }\n },\n\n /**\n * Load the virtual module that registers the custom Vue DevTools tab\n *\n * This code is served as a proper Vite module, allowing bare import\n * specifiers to be resolved through Vite's dependency pre-bundling.\n */\n load(id: string) {\n if (id === RESOLVED_VIRTUAL_DEVTOOLS_TAB_ID) {\n return `\nimport { addCustomTab } from '@vue/devtools-api';\n\ntry {\n // Route through Vite's proxy so it works in all environments\n const iframeSrc = window.location.origin + '/_devtools/';\n\n addCustomTab({\n name: 'vite-plugin-open-api-server',\n title: 'OpenAPI Server',\n icon: 'https://api.iconify.design/carbon:api-1.svg?width=24&height=24&color=%2394a3b8',\n view: {\n type: 'iframe',\n src: iframeSrc,\n },\n category: 'app',\n });\n} catch (e) {\n // @vue/devtools-api not available - expected when the package is not installed\n}\n`;\n }\n },\n\n /**\n * Configure the Vite dev server\n *\n * This hook is called when the dev server is created.\n * We use it to:\n * 1. Start the OpenAPI mock server\n * 2. Configure the Vite proxy to forward API requests\n * 3. Set up file watching for hot reload\n */\n async configureServer(viteServer: ViteDevServer): Promise<void> {\n vite = viteServer;\n cwd = viteServer.config.root;\n\n // Check if plugin is disabled\n if (!resolvedOptions.enabled) {\n return;\n }\n\n try {\n // Load handlers from handlers directory (using Vite's ssrLoadModule for TS support)\n const handlersResult = await loadHandlers(resolvedOptions.handlersDir, viteServer, cwd);\n\n // Load seeds from seeds directory (using Vite's ssrLoadModule for TS support)\n const seedsResult = await loadSeeds(resolvedOptions.seedsDir, viteServer, cwd);\n\n // Resolve DevTools SPA directory (shipped inside this package's dist/)\n let devtoolsSpaDir: string | undefined;\n if (resolvedOptions.devtools) {\n const pluginDir = dirname(fileURLToPath(import.meta.url));\n const spaDir = join(pluginDir, 'devtools-spa');\n if (existsSync(spaDir)) {\n devtoolsSpaDir = spaDir;\n } else {\n resolvedOptions.logger?.warn?.(\n '[vite-plugin-open-api-server] DevTools SPA not found at',\n spaDir,\n '- serving placeholder. Run \"pnpm build\" to include the SPA.',\n );\n }\n }\n\n // Create the OpenAPI mock server\n server = await createOpenApiServer({\n spec: resolvedOptions.spec,\n port: resolvedOptions.port,\n idFields: resolvedOptions.idFields,\n handlers: handlersResult.handlers,\n // Seeds are populated via executeSeeds, not directly\n seeds: new Map(),\n timelineLimit: resolvedOptions.timelineLimit,\n devtools: resolvedOptions.devtools,\n devtoolsSpaDir,\n cors: resolvedOptions.cors,\n corsOrigin: resolvedOptions.corsOrigin,\n logger: resolvedOptions.logger,\n });\n\n // Execute seeds to populate the store\n if (seedsResult.seeds.size > 0) {\n await executeSeeds(seedsResult.seeds, server.store, server.document);\n }\n\n // Start the mock server\n await server.start();\n\n // Configure Vite proxy\n configureProxy(viteServer, resolvedOptions.proxyPath, resolvedOptions.port);\n\n // Print startup banner\n const bannerInfo = extractBannerInfo(\n server.registry,\n {\n info: {\n title: server.document.info?.title ?? 'OpenAPI Server',\n version: server.document.info?.version ?? '1.0.0',\n },\n },\n handlersResult.handlers.size,\n seedsResult.seeds.size,\n resolvedOptions,\n );\n printBanner(bannerInfo, resolvedOptions);\n\n // Set up file watching for hot reload\n await setupFileWatching();\n } catch (error) {\n printError('Failed to start OpenAPI mock server', error, resolvedOptions);\n throw error;\n }\n },\n\n /**\n * Clean up when Vite server closes\n */\n async closeBundle(): Promise<void> {\n await cleanup();\n },\n\n /**\n * Inject Vue DevTools custom tab registration script\n *\n * When devtools is enabled, this injects a script tag that loads the\n * virtual module for custom tab registration. Using a virtual module\n * (instead of an inline script) ensures that bare import specifiers\n * like `@vue/devtools-api` are resolved through Vite's module pipeline.\n */\n transformIndexHtml() {\n if (!resolvedOptions.devtools || !resolvedOptions.enabled) {\n return;\n }\n\n return [\n {\n tag: 'script',\n attrs: { type: 'module', src: `/@id/${VIRTUAL_DEVTOOLS_TAB_ID}` },\n injectTo: 'head' as const,\n },\n ];\n },\n };\n\n /**\n * Configure Vite proxy for API requests\n *\n * @param vite - Vite dev server\n * @param proxyPath - Base path to proxy\n * @param port - Mock server port\n */\n function configureProxy(vite: ViteDevServer, proxyPath: string, port: number): void {\n // Ensure server config exists (create mutable copy if needed)\n const serverConfig = vite.config.server ?? {};\n const proxyConfig = serverConfig.proxy ?? {};\n\n // Escape special regex characters in proxy path and pre-compile regex\n const escapedPath = proxyPath.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const pathPrefixRegex = new RegExp(`^${escapedPath}`);\n\n // Add proxy configuration for API requests\n proxyConfig[proxyPath] = {\n target: `http://localhost:${port}`,\n changeOrigin: true,\n // Remove the proxy path prefix when forwarding\n rewrite: (path: string) => path.replace(pathPrefixRegex, ''),\n };\n\n // Proxy internal routes so they work through Vite's dev server port\n proxyConfig['/_devtools'] = {\n target: `http://localhost:${port}`,\n changeOrigin: true,\n };\n\n proxyConfig['/_api'] = {\n target: `http://localhost:${port}`,\n changeOrigin: true,\n };\n\n proxyConfig['/_ws'] = {\n target: `http://localhost:${port}`,\n changeOrigin: true,\n ws: true,\n };\n\n // Update the proxy config (Vite's proxy is mutable)\n if (vite.config.server) {\n vite.config.server.proxy = proxyConfig;\n }\n }\n\n /**\n * Set up file watching for hot reload\n */\n async function setupFileWatching(): Promise<void> {\n if (!server || !vite) return;\n\n // Debounce reload functions to prevent rapid-fire reloads\n const debouncedHandlerReload = debounce(reloadHandlers, 100);\n const debouncedSeedReload = debounce(reloadSeeds, 100);\n\n fileWatcher = await createFileWatcher({\n handlersDir: resolvedOptions.handlersDir,\n seedsDir: resolvedOptions.seedsDir,\n cwd,\n onHandlerChange: debouncedHandlerReload,\n onSeedChange: debouncedSeedReload,\n });\n }\n\n /**\n * Reload handlers when files change\n */\n async function reloadHandlers(): Promise<void> {\n if (!server || !vite) return;\n\n try {\n const handlersResult = await loadHandlers(resolvedOptions.handlersDir, vite, cwd);\n server.updateHandlers(handlersResult.handlers);\n\n // Notify via WebSocket\n server.wsHub.broadcast({\n type: 'handlers:updated',\n data: { count: handlersResult.handlers.size },\n });\n\n printReloadNotification('handlers', handlersResult.handlers.size, resolvedOptions);\n } catch (error) {\n printError('Failed to reload handlers', error, resolvedOptions);\n }\n }\n\n /**\n * Reload seeds when files change\n *\n * Note: This operation is not fully atomic - there's a brief window between\n * clearing the store and repopulating it where requests may see empty data.\n * For development tooling, this tradeoff is acceptable.\n */\n async function reloadSeeds(): Promise<void> {\n if (!server || !vite) return;\n\n try {\n // Load seeds first (before clearing) to minimize the window where store is empty\n const seedsResult = await loadSeeds(resolvedOptions.seedsDir, vite, cwd);\n\n // Only clear and repopulate if we successfully loaded seeds\n // This prevents clearing the store on load errors\n if (seedsResult.seeds.size > 0) {\n // Clear and immediately repopulate - minimizes empty window\n server.store.clearAll();\n await executeSeeds(seedsResult.seeds, server.store, server.document);\n } else {\n // User removed all seed files - clear the store\n server.store.clearAll();\n }\n\n // Notify via WebSocket\n server.wsHub.broadcast({\n type: 'seeds:updated',\n data: { count: seedsResult.seeds.size },\n });\n\n printReloadNotification('seeds', seedsResult.seeds.size, resolvedOptions);\n } catch (error) {\n printError('Failed to reload seeds', error, resolvedOptions);\n }\n }\n\n /**\n * Clean up resources\n */\n async function cleanup(): Promise<void> {\n // Close file watcher\n if (fileWatcher) {\n await fileWatcher.close();\n fileWatcher = null;\n }\n\n // Stop mock server\n if (server) {\n await server.stop();\n server = null;\n }\n\n vite = null;\n }\n}\n","/**\n * Vue DevTools Integration\n *\n * What: Provides a function to register OpenAPI Server in Vue DevTools\n * How: Uses @vue/devtools-api to add a custom tab with iframe to DevTools SPA\n * Why: Enables debugging and inspection of the mock API server within Vue DevTools\n *\n * @module devtools\n */\n\nimport type { App } from 'vue';\n\n/**\n * Options for registering the DevTools plugin\n */\nexport interface RegisterDevToolsOptions {\n /**\n * The port where the OpenAPI server is running\n * @default 3000\n */\n port?: number;\n\n /**\n * The host where the OpenAPI server is running\n * @default 'localhost' (or derived from window.location.hostname if in browser)\n */\n host?: string;\n\n /**\n * The protocol to use for the DevTools URL\n * @default 'http' (or derived from window.location.protocol if in browser)\n */\n protocol?: 'http' | 'https';\n\n /**\n * Enable or disable DevTools registration\n * @default true\n */\n enabled?: boolean;\n\n /**\n * Custom label for the DevTools tab\n * @default 'OpenAPI Server'\n */\n label?: string;\n}\n\n/**\n * Register OpenAPI Server in Vue DevTools\n *\n * This function should be called in your Vue application's main entry point\n * to add a custom tab to Vue DevTools. The tab contains an iframe that loads\n * the OpenAPI Server DevTools SPA.\n *\n * @example\n * ```typescript\n * // In your main.ts or main.js\n * import { createApp } from 'vue';\n * import { registerDevTools } from '@websublime/vite-plugin-open-api-server';\n * import App from './App.vue';\n *\n * const app = createApp(App);\n *\n * // Register OpenAPI Server DevTools\n * if (import.meta.env.DEV) {\n * await registerDevTools(app, { port: 3000 });\n * }\n *\n * app.mount('#app');\n * ```\n *\n * @param app - Vue application instance\n * @param options - Configuration options\n */\nexport async function registerDevTools(\n app: App,\n options: RegisterDevToolsOptions = {},\n): Promise<void> {\n const { enabled = true, label = 'OpenAPI Server', port, host, protocol } = options;\n\n // Validate app parameter\n if (!app || typeof app !== 'object') {\n // biome-ignore lint/suspicious/noConsole: Intentional warning for invalid app instance\n console.warn('[OpenAPI DevTools] Invalid Vue app instance provided');\n return;\n }\n\n // Only register if enabled\n if (!enabled) {\n return;\n }\n\n // Check if running in browser environment\n if (typeof window === 'undefined') {\n return;\n }\n\n // Lazy import to avoid SSR issues\n try {\n const { addCustomTab } = await import('@vue/devtools-api');\n\n // Get the DevTools URL\n const devtoolsUrl = getDevToolsUrl(port, host, protocol);\n\n // Add custom tab with iframe to Vue DevTools\n addCustomTab({\n name: 'vite-plugin-open-api-server',\n title: label,\n icon: 'data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%234f46e5%22 stroke-width=%222%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z%22/%3E%3Cpolyline points=%223.29 7 12 12 20.71 7%22/%3E%3Cline x1=%2212%22 y1=%2222%22 x2=%2212%22 y2=%2212%22/%3E%3C/svg%3E',\n view: {\n type: 'iframe',\n src: devtoolsUrl,\n },\n category: 'app',\n });\n } catch (error) {\n // Log warning but don't crash the app\n // DevTools integration is optional, so the app should continue working\n // biome-ignore lint/suspicious/noConsole: Intentional warning for registration failure\n console.warn('[OpenAPI DevTools] Failed to register with Vue DevTools:', error);\n }\n}\n\n/**\n * Get the DevTools URL for the given configuration\n *\n * When running in a browser, protocol and host are automatically derived from\n * window.location if not explicitly provided.\n *\n * @param port - Server port (default: 3000)\n * @param host - Server host (default: 'localhost' or window.location.hostname)\n * @param protocol - Protocol to use (default: 'http' or window.location.protocol)\n * @returns DevTools SPA URL\n */\nexport function getDevToolsUrl(port = 3000, host?: string, protocol?: 'http' | 'https'): string {\n // Derive defaults from browser environment if available\n const actualProtocol =\n protocol ||\n (typeof window !== 'undefined'\n ? (window.location.protocol.replace(':', '') as 'http' | 'https')\n : 'http');\n const actualHost =\n host || (typeof window !== 'undefined' ? window.location.hostname : 'localhost');\n\n return `${actualProtocol}://${actualHost}:${port}/_devtools/`;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/banner.ts","../src/utils.ts","../src/handlers.ts","../src/hot-reload.ts","../src/seeds.ts","../src/types.ts","../src/plugin.ts","../src/devtools.ts"],"names":["path","fg","require","vite"],"mappings":";;;;;;;;;;AA0CO,SAAS,WAAA,CAAY,MAAkB,OAAA,EAAgC;AAC5E,EAAA,IAAI,QAAQ,MAAA,EAAQ;AAClB,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,IAAU,OAAA;AACjC,EAAA,MAAM,GAAA,GAAM,CAAC,GAAA,KAAgB,MAAA,CAAO,KAAK,GAAG,CAAA;AAG5C,EAAA,MAAM,GAAA,GAAM;AAAA,IACV,OAAA,EAAS,QAAA;AAAA,IACT,QAAA,EAAU,QAAA;AAAA,IACV,UAAA,EAAY,QAAA;AAAA,IACZ,WAAA,EAAa,QAAA;AAAA,IACb,UAAA,EAAY,QAAA;AAAA,IACZ,QAAA,EAAU;AAAA,GACZ;AAEA,EAAA,MAAM,KAAA,GAAQ,EAAA;AACd,EAAA,MAAM,cAAA,GAAiB,GAAA,CAAI,UAAA,CAAW,MAAA,CAAO,QAAQ,CAAC,CAAA;AAEtD,EAAA,GAAA,CAAI,EAAE,CAAA;AACN,EAAA,GAAA,CAAI,EAAA,CAAG,IAAA,CAAK,CAAA,EAAG,GAAA,CAAI,OAAO,CAAA,EAAG,cAAc,CAAA,EAAG,GAAA,CAAI,QAAQ,CAAA,CAAE,CAAC,CAAA;AAC7D,EAAA,GAAA;AAAA,IACE,EAAA,CAAG,IAAA,CAAK,GAAA,CAAI,QAAQ,CAAA,GAAI,UAAA,CAAW,+BAAA,EAA0B,KAAA,GAA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A;AAAA,EACF;AAGA,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA;AAAA,EACF;AAGA,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,YAAA,EAAa,GAAI,MAAM,OAAO,mBAAmB,CAAA;AAGzD,IAAA,MAAM,WAAA,GAAc,cAAA,CAAe,IAAA,EAAM,IAAA,EAAM,QAAQ,CAAA;AAGvD,IAAA,YAAA,CAAa;AAAA,MACX,IAAA,EAAM,6BAAA;AAAA,MACN,KAAA,EAAO,KAAA;AAAA,MACP,IAAA,EAAM,mdAAA;AAAA,MACN,IAAA,EAAM;AAAA,QACJ,IAAA,EAAM,QAAA;AAAA,QACN,GAAA,EAAK;AAAA,OACP;AAAA,MACA,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH,SAAS,KAAA,EAAO;AAId,IAAA,OAAA,CAAQ,IAAA,CAAK,4DAA4D,KAAK,CAAA;AAAA,EAChF;AACF;AAaO,SAAS,cAAA,CAAe,IAAA,GAAO,GAAA,EAAM,IAAA,EAAe,QAAA,EAAqC;AAE9F,EAAA,MAAM,cAAA,GACJ,QAAA,KACC,OAAO,MAAA,KAAW,WAAA,GACd,MAAA,CAAO,QAAA,CAAS,QAAA,CAAS,OAAA,CAAQ,GAAA,EAAK,EAAE,CAAA,GACzC,MAAA,CAAA;AACN,EAAA,MAAM,aACJ,IAAA,KAAS,OAAO,WAAW,WAAA,GAAc,MAAA,CAAO,SAAS,QAAA,GAAW,WAAA,CAAA;AAEtE,EAAA,OAAO,CAAA,EAAG,cAAc,CAAA,GAAA,EAAM,UAAU,IAAI,IAAI,CAAA,WAAA,CAAA;AAClD","file":"index.js","sourcesContent":["/**\n * Startup Banner\n *\n * What: Prints a colorful startup banner with server information\n * How: Uses picocolors for ANSI color output\n * Why: Provides clear feedback about server status and configuration\n *\n * @module banner\n */\n\nimport type { EndpointRegistry } from '@websublime/vite-plugin-open-api-core';\nimport pc from 'picocolors';\nimport type { ResolvedOptions } from './types.js';\n\n/**\n * Banner configuration\n */\nexport interface BannerInfo {\n /** Server port */\n port: number;\n /** Proxy path in Vite */\n proxyPath: string;\n /** OpenAPI spec title */\n title: string;\n /** OpenAPI spec version */\n version: string;\n /** Number of endpoints */\n endpointCount: number;\n /** Number of loaded handlers */\n handlerCount: number;\n /** Number of loaded seeds */\n seedCount: number;\n /** DevTools enabled */\n devtools: boolean;\n}\n\n/**\n * Print the startup banner\n *\n * @param info - Banner information\n * @param options - Resolved plugin options\n */\nexport function printBanner(info: BannerInfo, options: ResolvedOptions): void {\n if (options.silent) {\n return;\n }\n\n const logger = options.logger ?? console;\n const log = (msg: string) => logger.info(msg);\n\n // Box drawing characters\n const BOX = {\n topLeft: '╭',\n topRight: '╮',\n bottomLeft: '╰',\n bottomRight: '╯',\n horizontal: '─',\n vertical: '│',\n };\n\n const width = 56;\n const horizontalLine = BOX.horizontal.repeat(width - 2);\n\n log('');\n log(pc.cyan(`${BOX.topLeft}${horizontalLine}${BOX.topRight}`));\n log(\n pc.cyan(BOX.vertical) + centerText('🚀 OpenAPI Mock Server', width - 2) + pc.cyan(BOX.vertical),\n );\n log(pc.cyan(`${BOX.bottomLeft}${horizontalLine}${BOX.bottomRight}`));\n log('');\n\n // API Info\n log(\n ` ${pc.bold(pc.white('API:'))} ${pc.green(info.title)} ${pc.dim(`v${info.version}`)}`,\n );\n log(` ${pc.bold(pc.white('Server:'))} ${pc.cyan(`http://localhost:${info.port}`)}`);\n log(\n ` ${pc.bold(pc.white('Proxy:'))} ${pc.yellow(info.proxyPath)} ${pc.dim('→')} ${pc.dim(`localhost:${info.port}`)}`,\n );\n log('');\n\n // Stats\n const stats = [\n { label: 'Endpoints', value: info.endpointCount, color: pc.blue },\n { label: 'Handlers', value: info.handlerCount, color: pc.green },\n { label: 'Seeds', value: info.seedCount, color: pc.magenta },\n ];\n\n const statsLine = stats\n .map((s) => `${pc.dim(`${s.label}:`)} ${s.color(String(s.value))}`)\n .join(pc.dim(' │ '));\n log(` ${statsLine}`);\n log('');\n\n // DevTools\n if (info.devtools) {\n log(\n ` ${pc.bold(pc.white('DevTools:'))} ${pc.cyan(`http://localhost:${info.port}/_devtools`)}`,\n );\n log(` ${pc.bold(pc.white('API Info:'))} ${pc.cyan(`http://localhost:${info.port}/_api`)}`);\n log('');\n }\n\n // Footer\n log(pc.dim(' Press Ctrl+C to stop the server'));\n log('');\n}\n\n/**\n * Center text within a given width\n *\n * @param text - Text to center\n * @param width - Total width\n * @returns Centered text with padding\n */\n// biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape codes require control characters\nconst ANSI_ESCAPE_REGEX = /\\x1b\\[[0-9;]*m/g;\n\nfunction centerText(text: string, width: number): string {\n // Account for ANSI codes - get visible length\n const visibleLength = text.replace(ANSI_ESCAPE_REGEX, '').length;\n const padding = Math.max(0, width - visibleLength);\n const leftPad = Math.floor(padding / 2);\n const rightPad = padding - leftPad;\n return ' '.repeat(leftPad) + text + ' '.repeat(rightPad);\n}\n\n/**\n * Extract banner info from server registry and document\n *\n * Note: This is the v0.x single-spec banner. It will be redesigned for\n * multi-spec display in Task 1.7 (vite-qq9.7). Currently only shows the\n * first spec's information.\n *\n * @param registry - Endpoint registry\n * @param document - OpenAPI document\n * @param handlerCount - Number of loaded handlers\n * @param seedCount - Number of loaded seed schemas\n * @param options - Resolved options (must contain at least one spec)\n * @returns Banner info\n */\nexport function extractBannerInfo(\n registry: EndpointRegistry,\n document: { info: { title: string; version: string } },\n handlerCount: number,\n seedCount: number,\n options: ResolvedOptions,\n): BannerInfo {\n return {\n port: options.port,\n proxyPath: options.specs[0]?.proxyPath || '(pending resolution)',\n title: document.info.title,\n version: document.info.version,\n endpointCount: registry.endpoints.size,\n handlerCount,\n seedCount,\n devtools: options.devtools,\n };\n}\n\n/**\n * Print a hot reload notification\n *\n * @param type - Type of reload ('handlers' | 'seeds')\n * @param count - Number of reloaded items\n * @param options - Resolved options\n */\nexport function printReloadNotification(\n type: 'handlers' | 'seeds',\n count: number,\n options: ResolvedOptions,\n): void {\n if (options.silent) {\n return;\n }\n\n const logger = options.logger ?? console;\n const icon = type === 'handlers' ? '🔄' : '🌱';\n const label = type === 'handlers' ? 'Handlers' : 'Seeds';\n const color = type === 'handlers' ? pc.green : pc.magenta;\n\n logger.info(` ${icon} ${color(label)} reloaded: ${pc.bold(String(count))} ${type}`);\n}\n\n/**\n * Print an error message\n *\n * @param message - Error message\n * @param error - Optional error object\n * @param options - Resolved options\n */\nexport function printError(message: string, error: unknown, options: ResolvedOptions): void {\n const logger = options.logger ?? console;\n logger.error(`${pc.red('✖')} ${pc.bold(pc.red('Error:'))} ${message}`);\n if (error instanceof Error) {\n logger.error(pc.dim(` ${error.message}`));\n }\n}\n\n/**\n * Print a warning message\n *\n * @param message - Warning message\n * @param options - Resolved options\n */\nexport function printWarning(message: string, options: ResolvedOptions): void {\n if (options.silent) {\n return;\n }\n\n const logger = options.logger ?? console;\n logger.warn(`${pc.yellow('⚠')} ${pc.yellow('Warning:')} ${message}`);\n}\n","/**\n * Filesystem Utilities\n *\n * What: Shared utility functions for filesystem operations\n * How: Uses Node.js fs/promises module with error handling\n * Why: Provides reusable utilities for handler and seed loading\n *\n * @module utils\n */\n\n/**\n * Check if a directory exists\n *\n * @param dirPath - Path to check\n * @returns Promise resolving to true if directory exists\n */\nexport async function directoryExists(dirPath: string): Promise<boolean> {\n try {\n const fs = await import('node:fs/promises');\n const stats = await fs.stat(dirPath);\n return stats.isDirectory();\n } catch {\n return false;\n }\n}\n","/**\n * Handler Loading\n *\n * What: Loads handler files from a directory using glob patterns\n * How: Uses Vite's ssrLoadModule to transform and load TypeScript files\n * Why: Enables users to define custom handlers for operationIds in TypeScript\n *\n * @module handlers\n */\n\nimport path from 'node:path';\nimport type { HandlerDefinition, HandlerFn, Logger } from '@websublime/vite-plugin-open-api-core';\nimport fg from 'fast-glob';\nimport type { ViteDevServer } from 'vite';\nimport { directoryExists } from './utils.js';\n\n/**\n * Result of loading handlers\n */\nexport interface LoadHandlersResult {\n /** Map of operationId to handler function */\n handlers: Map<string, HandlerFn>;\n /** Number of handler files loaded */\n fileCount: number;\n /** List of loaded file paths (relative) */\n files: string[];\n}\n\n/**\n * Load handlers from a directory\n *\n * Searches for handler files matching the pattern `*.handlers.{ts,js,mjs}`\n * in the specified directory. Each file should export an object with\n * operationId keys and handler functions as values.\n *\n * Uses Vite's ssrLoadModule to transform TypeScript files on-the-fly.\n *\n * @example\n * ```typescript\n * // mocks/handlers/pets.handlers.ts\n * import { defineHandlers } from '@websublime/vite-plugin-open-api-core';\n *\n * export default defineHandlers({\n * getPetById: async ({ req, store }) => {\n * const pet = store.get('Pet', req.params.petId);\n * return pet ?? { status: 404, data: { message: 'Pet not found' } };\n * },\n * });\n * ```\n *\n * @param handlersDir - Directory to search for handler files\n * @param viteServer - Vite dev server instance for ssrLoadModule\n * @param cwd - Current working directory (defaults to process.cwd())\n * @param logger - Optional logger for warnings/errors\n * @returns Promise resolving to loaded handlers\n */\nexport async function loadHandlers(\n handlersDir: string,\n viteServer: ViteDevServer,\n cwd: string = process.cwd(),\n logger: Logger = console,\n): Promise<LoadHandlersResult> {\n const handlers = new Map<string, HandlerFn>();\n const absoluteDir = path.resolve(cwd, handlersDir);\n\n // Check if directory exists\n const dirExists = await directoryExists(absoluteDir);\n if (!dirExists) {\n return {\n handlers,\n fileCount: 0,\n files: [],\n };\n }\n\n // Find handler files (supports TypeScript via Vite's transform)\n const pattern = '**/*.handlers.{ts,js,mjs}';\n const files = await fg(pattern, {\n cwd: absoluteDir,\n absolute: false,\n onlyFiles: true,\n ignore: ['node_modules/**', 'dist/**'],\n });\n\n // Load each file using Vite's ssrLoadModule\n for (const file of files) {\n const absolutePath = path.join(absoluteDir, file);\n const fileHandlers = await loadHandlerFile(absolutePath, viteServer, logger);\n\n // Merge handlers\n for (const [operationId, handler] of Object.entries(fileHandlers)) {\n if (handlers.has(operationId)) {\n logger.warn(\n `[vite-plugin-open-api-server] Duplicate handler for operationId \"${operationId}\" in ${file}. Using last definition.`,\n );\n }\n handlers.set(operationId, handler);\n }\n }\n\n return {\n handlers,\n fileCount: files.length,\n files,\n };\n}\n\n/**\n * Load a single handler file using Vite's ssrLoadModule\n *\n * @param filePath - Absolute path to the handler file\n * @param viteServer - Vite dev server instance\n * @param logger - Logger for warnings/errors\n * @returns Promise resolving to handler definition object\n */\nasync function loadHandlerFile(\n filePath: string,\n viteServer: ViteDevServer,\n logger: Logger,\n): Promise<HandlerDefinition> {\n try {\n // Invalidate module cache for hot reload\n const moduleNode = viteServer.moduleGraph.getModuleById(filePath);\n if (moduleNode) {\n viteServer.moduleGraph.invalidateModule(moduleNode);\n }\n\n // Use Vite's ssrLoadModule to transform and load the file\n // This handles TypeScript, ESM, and other transforms automatically\n const module = await viteServer.ssrLoadModule(filePath);\n\n // Support both default export and named export\n const handlers = module.default ?? module.handlers ?? module;\n\n // Validate handlers object\n if (!handlers || typeof handlers !== 'object') {\n logger.warn(\n `[vite-plugin-open-api-server] Invalid handler file ${filePath}: expected object export`,\n );\n return {};\n }\n\n // Filter to only handler functions\n const validHandlers: HandlerDefinition = {};\n for (const [key, value] of Object.entries(handlers)) {\n if (typeof value === 'function') {\n validHandlers[key] = value as HandlerFn;\n }\n }\n\n return validHandlers;\n } catch (error) {\n logger.error(\n `[vite-plugin-open-api-server] Failed to load handler file ${filePath}:`,\n error instanceof Error ? error.message : error,\n );\n return {};\n }\n}\n\n/**\n * Get list of handler files in a directory\n *\n * Useful for file watching setup.\n *\n * @param handlersDir - Directory to search\n * @param cwd - Current working directory\n * @returns Promise resolving to list of absolute file paths\n */\nexport async function getHandlerFiles(\n handlersDir: string,\n cwd: string = process.cwd(),\n): Promise<string[]> {\n const absoluteDir = path.resolve(cwd, handlersDir);\n\n const dirExists = await directoryExists(absoluteDir);\n if (!dirExists) {\n return [];\n }\n\n const pattern = '**/*.handlers.{ts,js,mjs}';\n const files = await fg(pattern, {\n cwd: absoluteDir,\n absolute: true,\n onlyFiles: true,\n ignore: ['node_modules/**', 'dist/**'],\n });\n\n return files;\n}\n","/**\n * Hot Reload\n *\n * What: File watcher for hot reloading handlers and seeds\n * How: Uses chokidar to watch for file changes\n * Why: Enables rapid development iteration without server restart\n *\n * @module hot-reload\n *\n * TODO: Full implementation in Task 3.3\n * This module provides placeholder/basic functionality for Task 3.1\n */\n\nimport path from 'node:path';\nimport type { Logger } from '@websublime/vite-plugin-open-api-core';\nimport type { FSWatcher } from 'chokidar';\n\n/**\n * File watcher configuration\n */\nexport interface FileWatcherOptions {\n /** Directory containing handler files */\n handlersDir?: string;\n /** Directory containing seed files */\n seedsDir?: string;\n /** Callback when a handler file changes */\n onHandlerChange?: (filePath: string) => Promise<void> | void;\n /** Callback when a seed file changes */\n onSeedChange?: (filePath: string) => Promise<void> | void;\n /** Current working directory */\n cwd?: string;\n /** Logger for error messages */\n logger?: Logger;\n}\n\n/**\n * File watcher instance\n */\nexport interface FileWatcher {\n /** Close the watcher and release resources */\n close(): Promise<void>;\n /** Check if watcher is active */\n readonly isWatching: boolean;\n /** Promise that resolves when all watchers are ready */\n readonly ready: Promise<void>;\n}\n\n/**\n * Create a file watcher for handlers and seeds\n *\n * Watches for changes to handler and seed files and invokes\n * callbacks when changes are detected. Supports add, change,\n * and unlink events.\n *\n * @example\n * ```typescript\n * const watcher = await createFileWatcher({\n * handlersDir: './mocks/handlers',\n * seedsDir: './mocks/seeds',\n * onHandlerChange: async (file) => {\n * console.log('Handler changed:', file);\n * const handlers = await loadHandlers('./mocks/handlers');\n * server.updateHandlers(handlers.handlers);\n * },\n * onSeedChange: async (file) => {\n * console.log('Seed changed:', file);\n * const seeds = await loadSeeds('./mocks/seeds');\n * // Re-execute seeds...\n * },\n * });\n *\n * // Later, clean up\n * await watcher.close();\n * ```\n *\n * @param options - Watcher configuration\n * @returns Promise resolving to file watcher instance\n */\nexport async function createFileWatcher(options: FileWatcherOptions): Promise<FileWatcher> {\n const {\n handlersDir,\n seedsDir,\n onHandlerChange,\n onSeedChange,\n cwd = process.cwd(),\n logger = console,\n } = options;\n\n // Dynamic import chokidar to avoid bundling issues\n const { watch } = await import('chokidar');\n\n const watchers: FSWatcher[] = [];\n const readyPromises: Promise<void>[] = [];\n let isWatching = true;\n\n // Handler file patterns\n const handlerPattern = '**/*.handlers.{ts,js,mjs}';\n const seedPattern = '**/*.seeds.{ts,js,mjs}';\n\n /**\n * Wrapper to safely invoke async callbacks and log errors\n * Prevents unhandled promise rejections from file watcher events\n */\n const safeInvoke = (\n callback: (filePath: string) => Promise<void> | void,\n filePath: string,\n context: string,\n ): void => {\n Promise.resolve()\n .then(() => callback(filePath))\n .catch((error) => {\n logger.error(\n `[vite-plugin-open-api-server] ${context} callback error for ${filePath}:`,\n error,\n );\n });\n };\n\n // Watch handlers directory\n if (handlersDir && onHandlerChange) {\n const absoluteHandlersDir = path.resolve(cwd, handlersDir);\n const handlerWatcher = watch(handlerPattern, {\n cwd: absoluteHandlersDir,\n ignoreInitial: true,\n ignored: ['**/node_modules/**', '**/dist/**'],\n persistent: true,\n awaitWriteFinish: {\n stabilityThreshold: 100,\n pollInterval: 50,\n },\n });\n\n handlerWatcher.on('add', (file) => {\n const absolutePath = path.join(absoluteHandlersDir, file);\n safeInvoke(onHandlerChange, absolutePath, 'Handler add');\n });\n\n handlerWatcher.on('change', (file) => {\n const absolutePath = path.join(absoluteHandlersDir, file);\n safeInvoke(onHandlerChange, absolutePath, 'Handler change');\n });\n\n handlerWatcher.on('unlink', (file) => {\n const absolutePath = path.join(absoluteHandlersDir, file);\n safeInvoke(onHandlerChange, absolutePath, 'Handler unlink');\n });\n\n handlerWatcher.on('error', (error) => {\n logger.error('[vite-plugin-open-api-server] Handler watcher error:', error);\n });\n\n // Track ready promise for this watcher\n readyPromises.push(\n new Promise<void>((resolve) => {\n handlerWatcher.on('ready', () => resolve());\n }),\n );\n\n watchers.push(handlerWatcher);\n }\n\n // Watch seeds directory\n if (seedsDir && onSeedChange) {\n const absoluteSeedsDir = path.resolve(cwd, seedsDir);\n const seedWatcher = watch(seedPattern, {\n cwd: absoluteSeedsDir,\n ignoreInitial: true,\n ignored: ['**/node_modules/**', '**/dist/**'],\n persistent: true,\n awaitWriteFinish: {\n stabilityThreshold: 100,\n pollInterval: 50,\n },\n });\n\n seedWatcher.on('add', (file) => {\n const absolutePath = path.join(absoluteSeedsDir, file);\n safeInvoke(onSeedChange, absolutePath, 'Seed add');\n });\n\n seedWatcher.on('change', (file) => {\n const absolutePath = path.join(absoluteSeedsDir, file);\n safeInvoke(onSeedChange, absolutePath, 'Seed change');\n });\n\n seedWatcher.on('unlink', (file) => {\n const absolutePath = path.join(absoluteSeedsDir, file);\n safeInvoke(onSeedChange, absolutePath, 'Seed unlink');\n });\n\n seedWatcher.on('error', (error) => {\n logger.error('[vite-plugin-open-api-server] Seed watcher error:', error);\n });\n\n // Track ready promise for this watcher\n readyPromises.push(\n new Promise<void>((resolve) => {\n seedWatcher.on('ready', () => resolve());\n }),\n );\n\n watchers.push(seedWatcher);\n }\n\n // Create combined ready promise\n const readyPromise = Promise.all(readyPromises).then(() => {});\n\n return {\n async close(): Promise<void> {\n isWatching = false;\n await Promise.all(watchers.map((w) => w.close()));\n },\n get isWatching(): boolean {\n return isWatching;\n },\n get ready(): Promise<void> {\n return readyPromise;\n },\n };\n}\n\n/**\n * Debounce a function with async execution guard\n *\n * Useful for preventing multiple rapid reloads when\n * multiple files change at once (e.g., during save all).\n *\n * This implementation prevents overlapping async executions:\n * - If the function is already running, the call is queued\n * - When the running function completes, it executes with the latest args\n * - Multiple calls during execution are coalesced into one\n *\n * @param fn - Function to debounce (can be sync or async)\n * @param delay - Debounce delay in milliseconds\n * @returns Debounced function\n */\nexport function debounce<T extends (...args: unknown[]) => unknown>(\n fn: T,\n delay: number,\n): (...args: Parameters<T>) => void {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n let isRunning = false;\n let pendingArgs: Parameters<T> | null = null;\n\n const execute = async (...args: Parameters<T>): Promise<void> => {\n if (isRunning) {\n // Queue the latest args for execution after current run completes\n pendingArgs = args;\n return;\n }\n\n isRunning = true;\n try {\n // Wrap in try-catch to handle sync throws, then await for async rejections\n // This prevents both sync errors and async rejections from propagating\n try {\n await fn(...args);\n } catch {\n // Silently catch errors - the caller is responsible for error handling\n // This prevents unhandled rejections from breaking the debounce chain\n }\n } finally {\n isRunning = false;\n\n // If there were calls during execution, run with the latest args\n if (pendingArgs !== null) {\n const nextArgs = pendingArgs;\n pendingArgs = null;\n // Use setTimeout to avoid deep recursion\n setTimeout(() => execute(...nextArgs), 0);\n }\n }\n };\n\n return (...args: Parameters<T>): void => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n timeoutId = setTimeout(() => {\n timeoutId = null;\n execute(...args);\n }, delay);\n };\n}\n","/**\n * Seed Loading\n *\n * What: Loads seed files from a directory using glob patterns\n * How: Uses Vite's ssrLoadModule to transform and load TypeScript files\n * Why: Enables users to define seed data for schemas in TypeScript\n *\n * @module seeds\n */\n\nimport path from 'node:path';\nimport type { AnySeedFn, Logger, SeedDefinition } from '@websublime/vite-plugin-open-api-core';\nimport fg from 'fast-glob';\nimport type { ViteDevServer } from 'vite';\nimport { directoryExists } from './utils.js';\n\n/**\n * Result of loading seeds\n */\nexport interface LoadSeedsResult {\n /** Map of schema name to seed function */\n seeds: Map<string, AnySeedFn>;\n /** Number of seed files loaded */\n fileCount: number;\n /** List of loaded file paths (relative) */\n files: string[];\n}\n\n/**\n * Load seeds from a directory\n *\n * Searches for seed files matching the pattern `*.seeds.{ts,js,mjs}`\n * in the specified directory. Each file should export an object with\n * schema name keys and seed functions as values.\n *\n * Uses Vite's ssrLoadModule to transform TypeScript files on-the-fly.\n *\n * @example\n * ```typescript\n * // mocks/seeds/pets.seeds.ts\n * import { defineSeeds } from '@websublime/vite-plugin-open-api-core';\n *\n * export default defineSeeds({\n * Pet: ({ seed, faker }) => {\n * return seed.count(10, () => ({\n * id: faker.number.int({ min: 1, max: 1000 }),\n * name: faker.animal.dog(),\n * status: faker.helpers.arrayElement(['available', 'pending', 'sold']),\n * }));\n * },\n * });\n * ```\n *\n * @param seedsDir - Directory to search for seed files\n * @param viteServer - Vite dev server instance for ssrLoadModule\n * @param cwd - Current working directory (defaults to process.cwd())\n * @param logger - Optional logger for warnings/errors\n * @returns Promise resolving to loaded seeds\n */\nexport async function loadSeeds(\n seedsDir: string,\n viteServer: ViteDevServer,\n cwd: string = process.cwd(),\n logger: Logger = console,\n): Promise<LoadSeedsResult> {\n const seeds = new Map<string, AnySeedFn>();\n const absoluteDir = path.resolve(cwd, seedsDir);\n\n // Check if directory exists\n const dirExists = await directoryExists(absoluteDir);\n if (!dirExists) {\n return {\n seeds,\n fileCount: 0,\n files: [],\n };\n }\n\n // Find seed files (supports TypeScript via Vite's transform)\n const pattern = '**/*.seeds.{ts,js,mjs}';\n const files = await fg(pattern, {\n cwd: absoluteDir,\n absolute: false,\n onlyFiles: true,\n ignore: ['node_modules/**', 'dist/**'],\n });\n\n // Load each file using Vite's ssrLoadModule\n for (const file of files) {\n const absolutePath = path.join(absoluteDir, file);\n const fileSeeds = await loadSeedFile(absolutePath, viteServer, logger);\n\n // Merge seeds\n for (const [schemaName, seedFn] of Object.entries(fileSeeds)) {\n if (seeds.has(schemaName)) {\n logger.warn(\n `[vite-plugin-open-api-server] Duplicate seed for schema \"${schemaName}\" in ${file}. Using last definition.`,\n );\n }\n seeds.set(schemaName, seedFn);\n }\n }\n\n return {\n seeds,\n fileCount: files.length,\n files,\n };\n}\n\n/**\n * Load a single seed file using Vite's ssrLoadModule\n *\n * @param filePath - Absolute path to the seed file\n * @param viteServer - Vite dev server instance\n * @param logger - Logger for warnings/errors\n * @returns Promise resolving to seed definition object\n */\nasync function loadSeedFile(\n filePath: string,\n viteServer: ViteDevServer,\n logger: Logger,\n): Promise<SeedDefinition> {\n try {\n // Invalidate module cache for hot reload\n const moduleNode = viteServer.moduleGraph.getModuleById(filePath);\n if (moduleNode) {\n viteServer.moduleGraph.invalidateModule(moduleNode);\n }\n\n // Use Vite's ssrLoadModule to transform and load the file\n // This handles TypeScript, ESM, and other transforms automatically\n const module = await viteServer.ssrLoadModule(filePath);\n\n // Support both default export and named export\n const seeds = module.default ?? module.seeds ?? module;\n\n // Validate seeds object\n if (!seeds || typeof seeds !== 'object') {\n logger.warn(\n `[vite-plugin-open-api-server] Invalid seed file ${filePath}: expected object export`,\n );\n return {};\n }\n\n // Filter to only seed functions\n const validSeeds: SeedDefinition = {};\n for (const [key, value] of Object.entries(seeds)) {\n if (typeof value === 'function') {\n validSeeds[key] = value as AnySeedFn;\n }\n }\n\n return validSeeds;\n } catch (error) {\n logger.error(\n `[vite-plugin-open-api-server] Failed to load seed file ${filePath}:`,\n error instanceof Error ? error.message : error,\n );\n return {};\n }\n}\n\n/**\n * Get list of seed files in a directory\n *\n * Useful for file watching setup.\n *\n * @param seedsDir - Directory to search\n * @param cwd - Current working directory\n * @returns Promise resolving to list of absolute file paths\n */\nexport async function getSeedFiles(\n seedsDir: string,\n cwd: string = process.cwd(),\n): Promise<string[]> {\n const absoluteDir = path.resolve(cwd, seedsDir);\n\n const dirExists = await directoryExists(absoluteDir);\n if (!dirExists) {\n return [];\n }\n\n const pattern = '**/*.seeds.{ts,js,mjs}';\n const files = await fg(pattern, {\n cwd: absoluteDir,\n absolute: true,\n onlyFiles: true,\n ignore: ['node_modules/**', 'dist/**'],\n });\n\n return files;\n}\n","/**\n * Vite Plugin Types\n *\n * What: Type definitions for the OpenAPI server Vite plugin\n * How: Defines configuration options, resolved types, and validation errors\n * Why: Provides type safety and documentation for plugin consumers\n *\n * @module types\n */\n\nimport type { Logger } from '@websublime/vite-plugin-open-api-core';\n\n// =============================================================================\n// Validation Error Codes (Appendix B)\n// =============================================================================\n\n/**\n * Error codes for configuration validation errors.\n *\n * Used across Tasks 1.2–1.4 for typed error handling.\n * Matches TECHNICAL-SPECIFICATION-V2.md Appendix B.\n */\nexport type ValidationErrorCode =\n | 'SPEC_ID_MISSING'\n | 'SPEC_ID_DUPLICATE'\n | 'PROXY_PATH_MISSING'\n | 'PROXY_PATH_TOO_BROAD'\n | 'PROXY_PATH_DUPLICATE'\n | 'PROXY_PATH_OVERLAP'\n | 'SPEC_NOT_FOUND'\n | 'SPECS_EMPTY';\n\n/**\n * Typed validation error for configuration issues.\n *\n * Thrown by resolveOptions() and validation functions in spec-id.ts\n * and proxy-path.ts. Consumers can catch and inspect the `code` field\n * for programmatic error handling.\n *\n * @example\n * ```typescript\n * try {\n * resolveOptions({ specs: [] });\n * } catch (error) {\n * if (error instanceof ValidationError && error.code === 'SPECS_EMPTY') {\n * // handle empty specs\n * }\n * }\n * ```\n */\nexport class ValidationError extends Error {\n readonly code: ValidationErrorCode;\n\n constructor(code: ValidationErrorCode, message: string) {\n super(message);\n this.name = 'ValidationError';\n this.code = code;\n }\n}\n\n// =============================================================================\n// User-Facing Configuration Types\n// =============================================================================\n\n/**\n * Configuration for a single OpenAPI spec instance\n *\n * @example\n * ```typescript\n * const petstore: SpecConfig = {\n * spec: './openapi/petstore.yaml',\n * id: 'petstore',\n * proxyPath: '/api/v3',\n * handlersDir: './mocks/petstore/handlers',\n * seedsDir: './mocks/petstore/seeds',\n * idFields: { Pet: 'petId' },\n * };\n * ```\n */\nexport interface SpecConfig {\n /**\n * Path to OpenAPI spec file (required)\n *\n * Supports: file paths, URLs, YAML, JSON\n *\n * @example './openapi/petstore.yaml'\n * @example 'https://petstore3.swagger.io/api/v3/openapi.json'\n */\n spec: string;\n\n /**\n * Unique identifier for this spec instance\n *\n * Used for routing, DevTools grouping, logging, default directory names.\n * If omitted, auto-derived from spec's info.title (slugified).\n *\n * @example 'petstore'\n */\n id?: string;\n\n /**\n * Base path for request proxy\n *\n * If omitted, auto-derived from spec's servers[0].url.\n * Must be unique across all specs.\n *\n * @example '/api/v3'\n */\n proxyPath?: string;\n\n /**\n * Directory containing handler files for this spec\n * @default './mocks/{specId}/handlers'\n */\n handlersDir?: string;\n\n /**\n * Directory containing seed files for this spec\n * @default './mocks/{specId}/seeds'\n */\n seedsDir?: string;\n\n /**\n * ID field configuration per schema for this spec\n * @default {} (uses 'id' for all schemas)\n */\n idFields?: Record<string, string>;\n}\n\n/**\n * Plugin configuration options\n *\n * @example\n * ```typescript\n * import { openApiServer } from '@websublime/vite-plugin-open-api-server';\n *\n * export default defineConfig({\n * plugins: [\n * openApiServer({\n * specs: [\n * { spec: './openapi/petstore.yaml' },\n * { spec: './openapi/inventory.yaml', id: 'inventory' },\n * ],\n * port: 4000,\n * }),\n * ],\n * });\n * ```\n */\nexport interface OpenApiServerOptions {\n /**\n * Array of OpenAPI spec configurations (required)\n * Each entry runs as an isolated instance.\n */\n specs: SpecConfig[];\n\n /**\n * Server port — all spec instances share this port\n * @default 4000\n */\n port?: number;\n\n /**\n * Enable/disable plugin\n * @default true\n */\n enabled?: boolean;\n\n /**\n * Maximum timeline events per spec\n * @default 500\n */\n timelineLimit?: number;\n\n /**\n * Enable DevTools integration\n * @default true\n */\n devtools?: boolean;\n\n /**\n * Enable CORS\n * @default true\n */\n cors?: boolean;\n\n /**\n * CORS origin configuration\n * @default '*'\n */\n corsOrigin?: string | string[];\n\n /**\n * Custom logger instance\n */\n logger?: Logger;\n\n /**\n * Suppress startup banner\n * @default false\n */\n silent?: boolean;\n}\n\n// =============================================================================\n// Internal Resolved Types\n// =============================================================================\n\n/**\n * Resolved spec config with all defaults applied\n *\n * Exported for advanced use cases (e.g., custom orchestrators or\n * test utilities that need to inspect resolved configuration).\n */\nexport interface ResolvedSpecConfig {\n spec: string;\n /** Guaranteed to be set after orchestrator resolution */\n id: string;\n /** Guaranteed to be set after orchestrator resolution */\n proxyPath: string;\n /**\n * How proxyPath was determined — used for banner display.\n *\n * Set during static option resolution. The orchestrator (Task 1.7)\n * will pass this to the multi-spec banner so it can show\n * \"(auto-derived)\" vs \"(explicit)\" next to each proxy path.\n */\n proxyPathSource: 'auto' | 'explicit';\n handlersDir: string;\n seedsDir: string;\n idFields: Record<string, string>;\n}\n\n/**\n * Resolved options with defaults applied\n *\n * Exported for advanced use cases (e.g., custom orchestrators or\n * test utilities that need to inspect resolved configuration).\n */\nexport interface ResolvedOptions {\n specs: ResolvedSpecConfig[];\n port: number;\n enabled: boolean;\n timelineLimit: number;\n devtools: boolean;\n cors: boolean;\n corsOrigin: string | string[];\n silent: boolean;\n logger?: Logger;\n}\n\n// =============================================================================\n// Option Resolution\n// =============================================================================\n\n/**\n * Resolve options with defaults\n *\n * Note: spec ID and proxyPath resolution requires processing the OpenAPI document\n * first, so they are resolved later in the orchestrator.\n * This function only resolves static defaults.\n *\n * @param options - User-provided options\n * @returns Resolved options with all defaults applied\n * @throws {ValidationError} SPECS_EMPTY if specs array is missing or empty\n * @throws {ValidationError} SPEC_NOT_FOUND if a spec entry has empty spec field\n */\nfunction validateSpecs(specs: SpecConfig[]): void {\n if (!specs || !Array.isArray(specs) || specs.length === 0) {\n throw new ValidationError(\n 'SPECS_EMPTY',\n 'specs is required and must be a non-empty array of SpecConfig',\n );\n }\n\n for (let i = 0; i < specs.length; i++) {\n const spec = specs[i];\n if (!spec.spec || typeof spec.spec !== 'string' || spec.spec.trim() === '') {\n const identifier = spec.id ? ` (id: \"${spec.id}\")` : '';\n throw new ValidationError(\n 'SPEC_NOT_FOUND',\n `specs[${i}]${identifier}: spec field is required and must be a non-empty string (path or URL to OpenAPI spec)`,\n );\n }\n }\n}\n\nexport function resolveOptions(options: OpenApiServerOptions): ResolvedOptions {\n validateSpecs(options.specs);\n\n return {\n specs: options.specs.map((s) => ({\n spec: s.spec,\n id: s.id ?? '',\n proxyPath: s.proxyPath ?? '',\n proxyPathSource: s.proxyPath ? 'explicit' : 'auto',\n handlersDir: s.handlersDir ?? '',\n seedsDir: s.seedsDir ?? '',\n idFields: s.idFields ?? {},\n })),\n port: options.port ?? 4000,\n enabled: options.enabled ?? true,\n timelineLimit: options.timelineLimit ?? 500,\n devtools: options.devtools ?? true,\n cors: options.cors ?? true,\n corsOrigin: options.corsOrigin ?? '*',\n silent: options.silent ?? false,\n logger: options.logger,\n };\n}\n","/**\n * Vite Plugin Implementation\n *\n * What: Main Vite plugin for OpenAPI mock server\n * How: Uses configureServer hook to start mock server and configure proxy\n * Why: Integrates OpenAPI mock server seamlessly into Vite dev workflow\n *\n * @module plugin\n */\n\nimport { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n createOpenApiServer,\n executeSeeds,\n type OpenApiServer,\n} from '@websublime/vite-plugin-open-api-core';\nimport type { Plugin, ViteDevServer } from 'vite';\nimport { extractBannerInfo, printBanner, printError, printReloadNotification } from './banner.js';\nimport { loadHandlers } from './handlers.js';\nimport { createFileWatcher, debounce, type FileWatcher } from './hot-reload.js';\nimport { loadSeeds } from './seeds.js';\nimport { type OpenApiServerOptions, resolveOptions } from './types.js';\n\n/**\n * Create the OpenAPI Server Vite plugin\n *\n * This plugin starts a mock server based on an OpenAPI specification\n * and configures Vite to proxy API requests to it.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import vue from '@vitejs/plugin-vue';\n * import { openApiServer } from '@websublime/vite-plugin-open-api-server';\n *\n * export default defineConfig({\n * plugins: [\n * vue(),\n * openApiServer({\n * spec: './openapi/petstore.yaml',\n * port: 4000,\n * proxyPath: '/api',\n * handlersDir: './mocks/handlers',\n * seedsDir: './mocks/seeds',\n * }),\n * ],\n * });\n * ```\n *\n * @param options - Plugin configuration options\n * @returns Vite plugin\n */\n/**\n * Virtual module ID for the DevTools tab registration script.\n *\n * This script is served as a Vite module (not inline HTML) so that bare\n * import specifiers like `@vue/devtools-api` are resolved through Vite's\n * module pipeline. Inline `<script type=\"module\">` blocks in HTML are\n * executed directly by the browser, which cannot resolve bare specifiers.\n */\nconst VIRTUAL_DEVTOOLS_TAB_ID = 'virtual:open-api-devtools-tab';\nconst RESOLVED_VIRTUAL_DEVTOOLS_TAB_ID = `\\0${VIRTUAL_DEVTOOLS_TAB_ID}`;\n\nexport function openApiServer(options: OpenApiServerOptions): Plugin {\n const resolvedOptions = resolveOptions(options);\n\n // Server instance (created in configureServer)\n let server: OpenApiServer | null = null;\n\n // Vite dev server reference (needed for ssrLoadModule)\n let vite: ViteDevServer | null = null;\n\n // File watcher for hot reload\n let fileWatcher: FileWatcher | null = null;\n\n // Current working directory (set in configureServer)\n let cwd: string = process.cwd();\n\n return {\n name: 'vite-plugin-open-api-server',\n\n // Only active in dev mode\n apply: 'serve',\n\n /**\n * Ensure @vue/devtools-api is available for the DevTools tab module\n *\n * The virtual module imports from '@vue/devtools-api', which Vite needs\n * to pre-bundle so it can be resolved at runtime in the browser, even\n * though the host app may not have it as a direct dependency.\n */\n config() {\n if (!resolvedOptions.devtools || !resolvedOptions.enabled) {\n return;\n }\n\n // Only add to optimizeDeps if the package is actually resolvable\n // to avoid Vite warnings when the consumer hasn't installed it\n const require = createRequire(import.meta.url);\n try {\n require.resolve('@vue/devtools-api');\n } catch {\n return;\n }\n\n return {\n optimizeDeps: {\n include: ['@vue/devtools-api'],\n },\n };\n },\n\n /**\n * Resolve the virtual module for DevTools tab registration\n */\n resolveId(id: string) {\n if (id === VIRTUAL_DEVTOOLS_TAB_ID) {\n return RESOLVED_VIRTUAL_DEVTOOLS_TAB_ID;\n }\n },\n\n /**\n * Load the virtual module that registers the custom Vue DevTools tab\n *\n * This code is served as a proper Vite module, allowing bare import\n * specifiers to be resolved through Vite's dependency pre-bundling.\n */\n load(id: string) {\n if (id === RESOLVED_VIRTUAL_DEVTOOLS_TAB_ID) {\n return `\nimport { addCustomTab } from '@vue/devtools-api';\n\ntry {\n // Route through Vite's proxy so it works in all environments\n const iframeSrc = window.location.origin + '/_devtools/';\n\n addCustomTab({\n name: 'vite-plugin-open-api-server',\n title: 'OpenAPI Server',\n icon: 'https://api.iconify.design/carbon:api-1.svg?width=24&height=24&color=%2394a3b8',\n view: {\n type: 'iframe',\n src: iframeSrc,\n },\n category: 'app',\n });\n} catch (e) {\n // @vue/devtools-api not available - expected when the package is not installed\n}\n`;\n }\n },\n\n /**\n * Configure the Vite dev server\n *\n * This hook is called when the dev server is created.\n * We use it to:\n * 1. Start the OpenAPI mock server\n * 2. Configure the Vite proxy to forward API requests\n * 3. Set up file watching for hot reload\n */\n async configureServer(viteServer: ViteDevServer): Promise<void> {\n vite = viteServer;\n cwd = viteServer.config.root;\n\n // Check if plugin is disabled\n if (!resolvedOptions.enabled) {\n return;\n }\n\n try {\n // Load handlers from handlers directory (using Vite's ssrLoadModule for TS support)\n // @ts-expect-error TODO: plugin.ts will be rewritten in Task 1.7 (vite-qq9.7)\n const handlersResult = await loadHandlers(resolvedOptions.handlersDir, viteServer, cwd);\n\n // Load seeds from seeds directory (using Vite's ssrLoadModule for TS support)\n // @ts-expect-error TODO: plugin.ts will be rewritten in Task 1.7 (vite-qq9.7)\n const seedsResult = await loadSeeds(resolvedOptions.seedsDir, viteServer, cwd);\n\n // Resolve DevTools SPA directory (shipped inside this package's dist/)\n let devtoolsSpaDir: string | undefined;\n if (resolvedOptions.devtools) {\n const pluginDir = dirname(fileURLToPath(import.meta.url));\n const spaDir = join(pluginDir, 'devtools-spa');\n if (existsSync(spaDir)) {\n devtoolsSpaDir = spaDir;\n } else {\n resolvedOptions.logger?.warn?.(\n '[vite-plugin-open-api-server] DevTools SPA not found at',\n spaDir,\n '- serving placeholder. Run \"pnpm build\" to include the SPA.',\n );\n }\n }\n\n // Create the OpenAPI mock server\n // TODO: plugin.ts will be rewritten in Task 1.7 (vite-qq9.7)\n // Using 'as any' because v0.x plugin code references old single-spec shape\n // biome-ignore lint/suspicious/noExplicitAny: v0.x compat — plugin.ts rewritten in Task 1.7\n const opts = resolvedOptions as any;\n server = await createOpenApiServer({\n spec: opts.spec,\n port: opts.port,\n idFields: opts.idFields,\n handlers: handlersResult.handlers,\n // Seeds are populated via executeSeeds, not directly\n seeds: new Map(),\n timelineLimit: opts.timelineLimit,\n devtools: opts.devtools,\n devtoolsSpaDir,\n cors: opts.cors,\n corsOrigin: opts.corsOrigin,\n logger: opts.logger,\n });\n\n // Execute seeds to populate the store\n if (seedsResult.seeds.size > 0) {\n await executeSeeds(seedsResult.seeds, server.store, server.document);\n }\n\n // Start the mock server\n await server.start();\n\n // Configure Vite proxy\n // @ts-expect-error TODO: plugin.ts will be rewritten in Task 1.7 (vite-qq9.7)\n configureProxy(viteServer, resolvedOptions.proxyPath, resolvedOptions.port);\n\n // Print startup banner\n const bannerInfo = extractBannerInfo(\n server.registry,\n {\n info: {\n title: server.document.info?.title ?? 'OpenAPI Server',\n version: server.document.info?.version ?? '1.0.0',\n },\n },\n handlersResult.handlers.size,\n seedsResult.seeds.size,\n resolvedOptions,\n );\n printBanner(bannerInfo, resolvedOptions);\n\n // Set up file watching for hot reload\n await setupFileWatching();\n } catch (error) {\n printError('Failed to start OpenAPI mock server', error, resolvedOptions);\n throw error;\n }\n },\n\n /**\n * Clean up when Vite server closes\n */\n async closeBundle(): Promise<void> {\n await cleanup();\n },\n\n /**\n * Inject Vue DevTools custom tab registration script\n *\n * When devtools is enabled, this injects a script tag that loads the\n * virtual module for custom tab registration. Using a virtual module\n * (instead of an inline script) ensures that bare import specifiers\n * like `@vue/devtools-api` are resolved through Vite's module pipeline.\n */\n transformIndexHtml() {\n if (!resolvedOptions.devtools || !resolvedOptions.enabled) {\n return;\n }\n\n return [\n {\n tag: 'script',\n attrs: { type: 'module', src: `/@id/${VIRTUAL_DEVTOOLS_TAB_ID}` },\n injectTo: 'head' as const,\n },\n ];\n },\n };\n\n /**\n * Configure Vite proxy for API requests\n *\n * @param vite - Vite dev server\n * @param proxyPath - Base path to proxy\n * @param port - Mock server port\n */\n function configureProxy(vite: ViteDevServer, proxyPath: string, port: number): void {\n // Ensure server config exists (create mutable copy if needed)\n const serverConfig = vite.config.server ?? {};\n const proxyConfig = serverConfig.proxy ?? {};\n\n // Escape special regex characters in proxy path and pre-compile regex\n const escapedPath = proxyPath.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const pathPrefixRegex = new RegExp(`^${escapedPath}`);\n\n // Add proxy configuration for API requests\n proxyConfig[proxyPath] = {\n target: `http://localhost:${port}`,\n changeOrigin: true,\n // Remove the proxy path prefix when forwarding\n rewrite: (path: string) => path.replace(pathPrefixRegex, ''),\n };\n\n // Proxy internal routes so they work through Vite's dev server port\n proxyConfig['/_devtools'] = {\n target: `http://localhost:${port}`,\n changeOrigin: true,\n };\n\n proxyConfig['/_api'] = {\n target: `http://localhost:${port}`,\n changeOrigin: true,\n };\n\n proxyConfig['/_ws'] = {\n target: `http://localhost:${port}`,\n changeOrigin: true,\n ws: true,\n };\n\n // Update the proxy config (Vite's proxy is mutable)\n if (vite.config.server) {\n vite.config.server.proxy = proxyConfig;\n }\n }\n\n /**\n * Set up file watching for hot reload\n */\n async function setupFileWatching(): Promise<void> {\n if (!server || !vite) return;\n\n // Debounce reload functions to prevent rapid-fire reloads\n const debouncedHandlerReload = debounce(reloadHandlers, 100);\n const debouncedSeedReload = debounce(reloadSeeds, 100);\n\n // TODO: plugin.ts will be rewritten in Task 1.7 (vite-qq9.7)\n // biome-ignore lint/suspicious/noExplicitAny: v0.x compat — plugin.ts rewritten in Task 1.7\n const watchOpts = resolvedOptions as any;\n fileWatcher = await createFileWatcher({\n handlersDir: watchOpts.handlersDir,\n seedsDir: watchOpts.seedsDir,\n cwd,\n onHandlerChange: debouncedHandlerReload,\n onSeedChange: debouncedSeedReload,\n });\n }\n\n /**\n * Reload handlers when files change\n */\n async function reloadHandlers(): Promise<void> {\n if (!server || !vite) return;\n\n try {\n // TODO: plugin.ts will be rewritten in Task 1.7 (vite-qq9.7)\n const handlersResult = await loadHandlers(\n // biome-ignore lint/suspicious/noExplicitAny: v0.x compat — plugin.ts rewritten in Task 1.7\n (resolvedOptions as any).handlersDir,\n vite,\n cwd,\n );\n server.updateHandlers(handlersResult.handlers);\n\n // Notify via WebSocket\n server.wsHub.broadcast({\n type: 'handlers:updated',\n data: { count: handlersResult.handlers.size },\n });\n\n printReloadNotification('handlers', handlersResult.handlers.size, resolvedOptions);\n } catch (error) {\n printError('Failed to reload handlers', error, resolvedOptions);\n }\n }\n\n /**\n * Reload seeds when files change\n *\n * Note: This operation is not fully atomic - there's a brief window between\n * clearing the store and repopulating it where requests may see empty data.\n * For development tooling, this tradeoff is acceptable.\n */\n async function reloadSeeds(): Promise<void> {\n if (!server || !vite) return;\n\n try {\n // Load seeds first (before clearing) to minimize the window where store is empty\n // TODO: plugin.ts will be rewritten in Task 1.7 (vite-qq9.7)\n const seedsResult = await loadSeeds(\n // biome-ignore lint/suspicious/noExplicitAny: v0.x compat — plugin.ts rewritten in Task 1.7\n (resolvedOptions as any).seedsDir,\n vite,\n cwd,\n );\n\n // Only clear and repopulate if we successfully loaded seeds\n // This prevents clearing the store on load errors\n if (seedsResult.seeds.size > 0) {\n // Clear and immediately repopulate - minimizes empty window\n server.store.clearAll();\n await executeSeeds(seedsResult.seeds, server.store, server.document);\n } else {\n // User removed all seed files - clear the store\n server.store.clearAll();\n }\n\n // Notify via WebSocket\n server.wsHub.broadcast({\n type: 'seeds:updated',\n data: { count: seedsResult.seeds.size },\n });\n\n printReloadNotification('seeds', seedsResult.seeds.size, resolvedOptions);\n } catch (error) {\n printError('Failed to reload seeds', error, resolvedOptions);\n }\n }\n\n /**\n * Clean up resources\n */\n async function cleanup(): Promise<void> {\n // Close file watcher\n if (fileWatcher) {\n await fileWatcher.close();\n fileWatcher = null;\n }\n\n // Stop mock server\n if (server) {\n await server.stop();\n server = null;\n }\n\n vite = null;\n }\n}\n","/**\n * Vue DevTools Integration\n *\n * What: Provides a function to register OpenAPI Server in Vue DevTools\n * How: Uses @vue/devtools-api to add a custom tab with iframe to DevTools SPA\n * Why: Enables debugging and inspection of the mock API server within Vue DevTools\n *\n * @module devtools\n */\n\nimport type { App } from 'vue';\n\n/**\n * Options for registering the DevTools plugin\n */\nexport interface RegisterDevToolsOptions {\n /**\n * The port where the OpenAPI server is running\n * @default 3000\n */\n port?: number;\n\n /**\n * The host where the OpenAPI server is running\n * @default 'localhost' (or derived from window.location.hostname if in browser)\n */\n host?: string;\n\n /**\n * The protocol to use for the DevTools URL\n * @default 'http' (or derived from window.location.protocol if in browser)\n */\n protocol?: 'http' | 'https';\n\n /**\n * Enable or disable DevTools registration\n * @default true\n */\n enabled?: boolean;\n\n /**\n * Custom label for the DevTools tab\n * @default 'OpenAPI Server'\n */\n label?: string;\n}\n\n/**\n * Register OpenAPI Server in Vue DevTools\n *\n * This function should be called in your Vue application's main entry point\n * to add a custom tab to Vue DevTools. The tab contains an iframe that loads\n * the OpenAPI Server DevTools SPA.\n *\n * @example\n * ```typescript\n * // In your main.ts or main.js\n * import { createApp } from 'vue';\n * import { registerDevTools } from '@websublime/vite-plugin-open-api-server';\n * import App from './App.vue';\n *\n * const app = createApp(App);\n *\n * // Register OpenAPI Server DevTools\n * if (import.meta.env.DEV) {\n * await registerDevTools(app, { port: 3000 });\n * }\n *\n * app.mount('#app');\n * ```\n *\n * @param app - Vue application instance\n * @param options - Configuration options\n */\nexport async function registerDevTools(\n app: App,\n options: RegisterDevToolsOptions = {},\n): Promise<void> {\n const { enabled = true, label = 'OpenAPI Server', port, host, protocol } = options;\n\n // Validate app parameter\n if (!app || typeof app !== 'object') {\n // biome-ignore lint/suspicious/noConsole: Intentional warning for invalid app instance\n console.warn('[OpenAPI DevTools] Invalid Vue app instance provided');\n return;\n }\n\n // Only register if enabled\n if (!enabled) {\n return;\n }\n\n // Check if running in browser environment\n if (typeof window === 'undefined') {\n return;\n }\n\n // Lazy import to avoid SSR issues\n try {\n const { addCustomTab } = await import('@vue/devtools-api');\n\n // Get the DevTools URL\n const devtoolsUrl = getDevToolsUrl(port, host, protocol);\n\n // Add custom tab with iframe to Vue DevTools\n addCustomTab({\n name: 'vite-plugin-open-api-server',\n title: label,\n icon: 'data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%234f46e5%22 stroke-width=%222%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z%22/%3E%3Cpolyline points=%223.29 7 12 12 20.71 7%22/%3E%3Cline x1=%2212%22 y1=%2222%22 x2=%2212%22 y2=%2212%22/%3E%3C/svg%3E',\n view: {\n type: 'iframe',\n src: devtoolsUrl,\n },\n category: 'app',\n });\n } catch (error) {\n // Log warning but don't crash the app\n // DevTools integration is optional, so the app should continue working\n // biome-ignore lint/suspicious/noConsole: Intentional warning for registration failure\n console.warn('[OpenAPI DevTools] Failed to register with Vue DevTools:', error);\n }\n}\n\n/**\n * Get the DevTools URL for the given configuration\n *\n * When running in a browser, protocol and host are automatically derived from\n * window.location if not explicitly provided.\n *\n * @param port - Server port (default: 3000)\n * @param host - Server host (default: 'localhost' or window.location.hostname)\n * @param protocol - Protocol to use (default: 'http' or window.location.protocol)\n * @returns DevTools SPA URL\n */\nexport function getDevToolsUrl(port = 3000, host?: string, protocol?: 'http' | 'https'): string {\n // Derive defaults from browser environment if available\n const actualProtocol =\n protocol ||\n (typeof window !== 'undefined'\n ? (window.location.protocol.replace(':', '') as 'http' | 'https')\n : 'http');\n const actualHost =\n host || (typeof window !== 'undefined' ? window.location.hostname : 'localhost');\n\n return `${actualProtocol}://${actualHost}:${port}/_devtools/`;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websublime/vite-plugin-open-api-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0-next.0",
|
|
4
4
|
"description": "Vite plugin for OpenAPI mock server with DevTools integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
"directory": "packages/server"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"fast-glob": "^3.3.3",
|
|
27
26
|
"picocolors": "^1.1.1",
|
|
28
|
-
"chokidar": "^5.0.0",
|
|
29
27
|
"@vue/devtools-api": "^8.0.6",
|
|
30
|
-
"
|
|
28
|
+
"fast-glob": "^3.3.3",
|
|
29
|
+
"chokidar": "^5.0.0",
|
|
30
|
+
"@websublime/vite-plugin-open-api-core": "0.14.0-next.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
+
"typescript": "^5.9.0",
|
|
33
34
|
"tsup": "^8.5.0",
|
|
34
35
|
"vite": "^7.0.0",
|
|
35
|
-
"typescript": "^5.9.0",
|
|
36
36
|
"vue": "^3.5.27",
|
|
37
37
|
"@websublime/vite-plugin-open-api-devtools": "0.8.5"
|
|
38
38
|
},
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"module": "./dist/index.js",
|
|
56
56
|
"scripts": {
|
|
57
57
|
"dev": "tsup --watch",
|
|
58
|
+
"copy:devtools-spa": "node scripts/copy-devtools-spa.mjs",
|
|
58
59
|
"build": "tsup && pnpm run copy:devtools-spa",
|
|
59
|
-
"typecheck": "tsc --noEmit"
|
|
60
|
-
"copy:devtools-spa": "node scripts/copy-devtools-spa.mjs"
|
|
60
|
+
"typecheck": "tsc --noEmit"
|
|
61
61
|
}
|
|
62
62
|
}
|