@kubb/core 4.21.2 → 4.22.1
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/hooks.d.cts +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/index-BfAwjQCB.d.cts +255 -0
- package/dist/index-C0nP9vjm.d.ts +255 -0
- package/dist/index.cjs +156 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +127 -3
- package/dist/index.d.ts +127 -3
- package/dist/index.js +140 -4
- package/dist/index.js.map +1 -1
- package/dist/{types-Dv2RimvH.d.ts → types-Cn3Gwsf3.d.ts} +2 -82
- package/dist/{types-DalqcJjU.d.cts → types-ulibr7zw.d.cts} +2 -82
- package/dist/{getBarrelFiles-DCNjiX2W.cjs → utils-BclJP5UT.cjs} +350 -11
- package/dist/utils-BclJP5UT.cjs.map +1 -0
- package/dist/{getBarrelFiles-gRyVPFBP.js → utils-C3cuilmF.js} +281 -22
- package/dist/utils-C3cuilmF.js.map +1 -0
- package/dist/utils.cjs +24 -288
- package/dist/utils.d.cts +3 -226
- package/dist/utils.d.ts +3 -226
- package/dist/utils.js +3 -264
- package/package.json +3 -2
- package/schemas/openapi/server.yaml +524 -0
- package/src/index.ts +2 -0
- package/src/server/index.ts +281 -0
- package/src/types.ts +0 -2
- package/dist/getBarrelFiles-DCNjiX2W.cjs.map +0 -1
- package/dist/getBarrelFiles-D_2NWu2Q.d.ts +0 -35
- package/dist/getBarrelFiles-g6fYZe8A.d.cts +0 -35
- package/dist/getBarrelFiles-gRyVPFBP.js.map +0 -1
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.js.map +0 -1
- package/src/StreamEvents.ts +0 -71
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { t as __name } from "./chunk-DlpkT3g-.cjs";
|
|
2
|
-
import { A as
|
|
3
|
-
import {
|
|
2
|
+
import { A as AsyncEventEmitter, C as UserLogger, D as KubbEvents, E as PossiblePromise, O as PluginManager, S as UserConfig, T as UserPluginWithLifeCycle, _ as PluginLifecycleHooks, a as InputData, b as ResolveNameParams, c as Logger, d as Output, f as Plugin, g as PluginLifecycle, h as PluginKey, i as Group, k as getMode, l as LoggerContext, m as PluginFactoryOptions, n as Config, o as InputPath, p as PluginContext, r as GetPluginFactoryOptions, s as LogLevel, t as BarrelType, u as LoggerOptions, v as PluginParameter, w as UserPlugin, x as ResolvePathParams, y as PluginWithLifeCycle } from "./types-ulibr7zw.cjs";
|
|
3
|
+
import { m as getBarrelFiles, p as FileMetaBase } from "./index-BfAwjQCB.cjs";
|
|
4
4
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
5
5
|
import { Fabric } from "@kubb/react-fabric";
|
|
6
|
+
import { Server } from "node:http";
|
|
6
7
|
|
|
7
8
|
//#region src/BaseGenerator.d.ts
|
|
8
9
|
/**
|
|
@@ -156,5 +157,128 @@ declare class PromiseManager<TState = any> {
|
|
|
156
157
|
}): TOutput;
|
|
157
158
|
}
|
|
158
159
|
//#endregion
|
|
159
|
-
|
|
160
|
+
//#region src/server/index.d.ts
|
|
161
|
+
/**
|
|
162
|
+
* Typed SSE events sent by the Kubb server.
|
|
163
|
+
* Follows the same tuple structure as {@link KubbEvents}.
|
|
164
|
+
* Reusable in consumers like kubb-playground to parse incoming events.
|
|
165
|
+
*/
|
|
166
|
+
interface SseEvents {
|
|
167
|
+
'plugin:start': [plugin: {
|
|
168
|
+
name: string;
|
|
169
|
+
}];
|
|
170
|
+
'plugin:end': [plugin: {
|
|
171
|
+
name: string;
|
|
172
|
+
}, meta: {
|
|
173
|
+
duration: number;
|
|
174
|
+
success: boolean;
|
|
175
|
+
}];
|
|
176
|
+
'files:processing:start': [meta: {
|
|
177
|
+
total: number;
|
|
178
|
+
}];
|
|
179
|
+
'file:processing:update': [meta: {
|
|
180
|
+
file: string;
|
|
181
|
+
processed: number;
|
|
182
|
+
total: number;
|
|
183
|
+
percentage: number;
|
|
184
|
+
}];
|
|
185
|
+
'files:processing:end': [meta: {
|
|
186
|
+
total: number;
|
|
187
|
+
}];
|
|
188
|
+
info: [message: string, info?: string];
|
|
189
|
+
success: [message: string, info?: string];
|
|
190
|
+
warn: [message: string, info?: string];
|
|
191
|
+
error: [error: {
|
|
192
|
+
message: string;
|
|
193
|
+
stack?: string;
|
|
194
|
+
}];
|
|
195
|
+
'generation:start': [config: {
|
|
196
|
+
name?: string;
|
|
197
|
+
plugins: number;
|
|
198
|
+
}];
|
|
199
|
+
'generation:end': [Config: Config, files: Array<KubbFile.ResolvedFile>, sources: Record<KubbFile.Path, string>];
|
|
200
|
+
'lifecycle:end': [];
|
|
201
|
+
}
|
|
202
|
+
type SseEventType = keyof SseEvents;
|
|
203
|
+
type SseEvent<T extends SseEventType = SseEventType> = {
|
|
204
|
+
type: T;
|
|
205
|
+
data: SseEvents[T];
|
|
206
|
+
timestamp: number;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* API response types for the Kubb stream server endpoints.
|
|
210
|
+
*/
|
|
211
|
+
/** GET /api/health */
|
|
212
|
+
type HealthResponse = {
|
|
213
|
+
status: 'ok';
|
|
214
|
+
version: string;
|
|
215
|
+
configPath: string;
|
|
216
|
+
};
|
|
217
|
+
/** GET /api/info */
|
|
218
|
+
type InfoResponse = {
|
|
219
|
+
version: string;
|
|
220
|
+
configPath: string;
|
|
221
|
+
spec?: string;
|
|
222
|
+
config: {
|
|
223
|
+
name?: string;
|
|
224
|
+
root: string;
|
|
225
|
+
input: {
|
|
226
|
+
path?: string;
|
|
227
|
+
};
|
|
228
|
+
output: {
|
|
229
|
+
path: string;
|
|
230
|
+
write?: boolean;
|
|
231
|
+
extension?: Record<string, string>;
|
|
232
|
+
barrelType?: string | false;
|
|
233
|
+
};
|
|
234
|
+
plugins?: Array<{
|
|
235
|
+
name: string;
|
|
236
|
+
options: unknown;
|
|
237
|
+
}>;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Same events asd KubbEvents but with server lifecycle events
|
|
242
|
+
*/
|
|
243
|
+
type ServerEvents = KubbEvents & {
|
|
244
|
+
/**
|
|
245
|
+
* Emitted when the server starts successfully
|
|
246
|
+
*/
|
|
247
|
+
'server:start': [serverUrl: string, configPath: string];
|
|
248
|
+
/**
|
|
249
|
+
* Emitted when the server is shutting down
|
|
250
|
+
*/
|
|
251
|
+
'server:shutdown': [];
|
|
252
|
+
/**
|
|
253
|
+
* Emitted when the server has stopped
|
|
254
|
+
*/
|
|
255
|
+
'server:stopped': [];
|
|
256
|
+
};
|
|
257
|
+
type ServerOptions = {
|
|
258
|
+
port: number;
|
|
259
|
+
host: string;
|
|
260
|
+
configPath: string;
|
|
261
|
+
config: Config;
|
|
262
|
+
version: string;
|
|
263
|
+
/**
|
|
264
|
+
* Event emitter for both server lifecycle and generation events
|
|
265
|
+
*/
|
|
266
|
+
events: AsyncEventEmitter<ServerEvents>;
|
|
267
|
+
/**
|
|
268
|
+
* Callback to handle code generation
|
|
269
|
+
* Should use the events emitter to emit generation events
|
|
270
|
+
*/
|
|
271
|
+
onGenerate: () => Promise<void>;
|
|
272
|
+
};
|
|
273
|
+
declare function startServer({
|
|
274
|
+
port,
|
|
275
|
+
host,
|
|
276
|
+
configPath,
|
|
277
|
+
config,
|
|
278
|
+
version,
|
|
279
|
+
events,
|
|
280
|
+
onGenerate
|
|
281
|
+
}: ServerOptions): Promise<Server>;
|
|
282
|
+
//#endregion
|
|
283
|
+
export { BarrelType, BaseGenerator, type CLIOptions, Config, type FileMetaBase, GetPluginFactoryOptions, Group, type HealthResponse, type InfoResponse, InputData, InputPath, KubbEvents, LogLevel, Logger, LoggerContext, LoggerOptions, Output, PackageManager, Plugin, PluginContext, PluginFactoryOptions, PluginKey, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PluginWithLifeCycle, PromiseManager, ResolveNameParams, ResolvePathParams, type ServerEvents, type SseEvent, type SseEventType, type SseEvents, UserConfig, UserLogger, UserPlugin, UserPluginWithLifeCycle, build, build as default, defineConfig, defineLogger, definePlugin, getBarrelFiles, getMode, isInputPath, safeBuild, setup, startServer };
|
|
160
284
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { t as __name } from "./chunk-iVr_oF3V.js";
|
|
2
|
-
import { A as
|
|
3
|
-
import {
|
|
2
|
+
import { A as AsyncEventEmitter, C as UserLogger, D as KubbEvents, E as PossiblePromise, O as PluginManager, S as UserConfig, T as UserPluginWithLifeCycle, _ as PluginLifecycleHooks, a as InputData, b as ResolveNameParams, c as Logger, d as Output, f as Plugin, g as PluginLifecycle, h as PluginKey, i as Group, k as getMode, l as LoggerContext, m as PluginFactoryOptions, n as Config, o as InputPath, p as PluginContext, r as GetPluginFactoryOptions, s as LogLevel, t as BarrelType, u as LoggerOptions, v as PluginParameter, w as UserPlugin, x as ResolvePathParams, y as PluginWithLifeCycle } from "./types-Cn3Gwsf3.js";
|
|
3
|
+
import { m as getBarrelFiles, p as FileMetaBase } from "./index-C0nP9vjm.js";
|
|
4
4
|
import { Fabric } from "@kubb/react-fabric";
|
|
5
|
+
import { Server } from "node:http";
|
|
5
6
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
6
7
|
|
|
7
8
|
//#region src/BaseGenerator.d.ts
|
|
@@ -156,5 +157,128 @@ declare class PromiseManager<TState = any> {
|
|
|
156
157
|
}): TOutput;
|
|
157
158
|
}
|
|
158
159
|
//#endregion
|
|
159
|
-
|
|
160
|
+
//#region src/server/index.d.ts
|
|
161
|
+
/**
|
|
162
|
+
* Typed SSE events sent by the Kubb server.
|
|
163
|
+
* Follows the same tuple structure as {@link KubbEvents}.
|
|
164
|
+
* Reusable in consumers like kubb-playground to parse incoming events.
|
|
165
|
+
*/
|
|
166
|
+
interface SseEvents {
|
|
167
|
+
'plugin:start': [plugin: {
|
|
168
|
+
name: string;
|
|
169
|
+
}];
|
|
170
|
+
'plugin:end': [plugin: {
|
|
171
|
+
name: string;
|
|
172
|
+
}, meta: {
|
|
173
|
+
duration: number;
|
|
174
|
+
success: boolean;
|
|
175
|
+
}];
|
|
176
|
+
'files:processing:start': [meta: {
|
|
177
|
+
total: number;
|
|
178
|
+
}];
|
|
179
|
+
'file:processing:update': [meta: {
|
|
180
|
+
file: string;
|
|
181
|
+
processed: number;
|
|
182
|
+
total: number;
|
|
183
|
+
percentage: number;
|
|
184
|
+
}];
|
|
185
|
+
'files:processing:end': [meta: {
|
|
186
|
+
total: number;
|
|
187
|
+
}];
|
|
188
|
+
info: [message: string, info?: string];
|
|
189
|
+
success: [message: string, info?: string];
|
|
190
|
+
warn: [message: string, info?: string];
|
|
191
|
+
error: [error: {
|
|
192
|
+
message: string;
|
|
193
|
+
stack?: string;
|
|
194
|
+
}];
|
|
195
|
+
'generation:start': [config: {
|
|
196
|
+
name?: string;
|
|
197
|
+
plugins: number;
|
|
198
|
+
}];
|
|
199
|
+
'generation:end': [Config: Config, files: Array<KubbFile.ResolvedFile>, sources: Record<KubbFile.Path, string>];
|
|
200
|
+
'lifecycle:end': [];
|
|
201
|
+
}
|
|
202
|
+
type SseEventType = keyof SseEvents;
|
|
203
|
+
type SseEvent<T extends SseEventType = SseEventType> = {
|
|
204
|
+
type: T;
|
|
205
|
+
data: SseEvents[T];
|
|
206
|
+
timestamp: number;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* API response types for the Kubb stream server endpoints.
|
|
210
|
+
*/
|
|
211
|
+
/** GET /api/health */
|
|
212
|
+
type HealthResponse = {
|
|
213
|
+
status: 'ok';
|
|
214
|
+
version: string;
|
|
215
|
+
configPath: string;
|
|
216
|
+
};
|
|
217
|
+
/** GET /api/info */
|
|
218
|
+
type InfoResponse = {
|
|
219
|
+
version: string;
|
|
220
|
+
configPath: string;
|
|
221
|
+
spec?: string;
|
|
222
|
+
config: {
|
|
223
|
+
name?: string;
|
|
224
|
+
root: string;
|
|
225
|
+
input: {
|
|
226
|
+
path?: string;
|
|
227
|
+
};
|
|
228
|
+
output: {
|
|
229
|
+
path: string;
|
|
230
|
+
write?: boolean;
|
|
231
|
+
extension?: Record<string, string>;
|
|
232
|
+
barrelType?: string | false;
|
|
233
|
+
};
|
|
234
|
+
plugins?: Array<{
|
|
235
|
+
name: string;
|
|
236
|
+
options: unknown;
|
|
237
|
+
}>;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Same events asd KubbEvents but with server lifecycle events
|
|
242
|
+
*/
|
|
243
|
+
type ServerEvents = KubbEvents & {
|
|
244
|
+
/**
|
|
245
|
+
* Emitted when the server starts successfully
|
|
246
|
+
*/
|
|
247
|
+
'server:start': [serverUrl: string, configPath: string];
|
|
248
|
+
/**
|
|
249
|
+
* Emitted when the server is shutting down
|
|
250
|
+
*/
|
|
251
|
+
'server:shutdown': [];
|
|
252
|
+
/**
|
|
253
|
+
* Emitted when the server has stopped
|
|
254
|
+
*/
|
|
255
|
+
'server:stopped': [];
|
|
256
|
+
};
|
|
257
|
+
type ServerOptions = {
|
|
258
|
+
port: number;
|
|
259
|
+
host: string;
|
|
260
|
+
configPath: string;
|
|
261
|
+
config: Config;
|
|
262
|
+
version: string;
|
|
263
|
+
/**
|
|
264
|
+
* Event emitter for both server lifecycle and generation events
|
|
265
|
+
*/
|
|
266
|
+
events: AsyncEventEmitter<ServerEvents>;
|
|
267
|
+
/**
|
|
268
|
+
* Callback to handle code generation
|
|
269
|
+
* Should use the events emitter to emit generation events
|
|
270
|
+
*/
|
|
271
|
+
onGenerate: () => Promise<void>;
|
|
272
|
+
};
|
|
273
|
+
declare function startServer({
|
|
274
|
+
port,
|
|
275
|
+
host,
|
|
276
|
+
configPath,
|
|
277
|
+
config,
|
|
278
|
+
version,
|
|
279
|
+
events,
|
|
280
|
+
onGenerate
|
|
281
|
+
}: ServerOptions): Promise<Server>;
|
|
282
|
+
//#endregion
|
|
283
|
+
export { BarrelType, BaseGenerator, type CLIOptions, Config, type FileMetaBase, GetPluginFactoryOptions, Group, type HealthResponse, type InfoResponse, InputData, InputPath, KubbEvents, LogLevel, Logger, LoggerContext, LoggerOptions, Output, PackageManager, Plugin, PluginContext, PluginFactoryOptions, PluginKey, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PluginWithLifeCycle, PromiseManager, ResolveNameParams, ResolvePathParams, type ServerEvents, type SseEvent, type SseEventType, type SseEvents, UserConfig, UserLogger, UserPlugin, UserPluginWithLifeCycle, build, build as default, defineConfig, defineLogger, definePlugin, getBarrelFiles, getMode, isInputPath, safeBuild, setup, startServer };
|
|
160
284
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk-iVr_oF3V.js";
|
|
2
|
-
import {
|
|
2
|
+
import { E as BuildError, T as Queue, _ as formatMs, b as PluginManager, h as URLPath, l as getBarrelFiles, n as serializePluginOptions, v as getElapsedMs, w as PromiseManager, x as getMode, y as AsyncEventEmitter } from "./utils-C3cuilmF.js";
|
|
3
3
|
import { a as exists, i as readSync, n as getRelativePath, o as clean, r as read, t as write } from "./fs-Parec-wn.js";
|
|
4
4
|
import "./transformers-8ju9ixkG.js";
|
|
5
5
|
import mod from "node:module";
|
|
@@ -10,8 +10,9 @@ import { fsPlugin } from "@kubb/react-fabric/plugins";
|
|
|
10
10
|
import process$1, { version } from "node:process";
|
|
11
11
|
import os from "node:os";
|
|
12
12
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
13
|
-
import fs, { promises } from "node:fs";
|
|
13
|
+
import fs, { promises, readFileSync } from "node:fs";
|
|
14
14
|
import { coerce, satisfies } from "semver";
|
|
15
|
+
import { createServer } from "node:http";
|
|
15
16
|
|
|
16
17
|
//#region src/BaseGenerator.ts
|
|
17
18
|
/**
|
|
@@ -68,7 +69,7 @@ function isInputPath(config) {
|
|
|
68
69
|
|
|
69
70
|
//#endregion
|
|
70
71
|
//#region package.json
|
|
71
|
-
var version$1 = "4.
|
|
72
|
+
var version$1 = "4.22.1";
|
|
72
73
|
|
|
73
74
|
//#endregion
|
|
74
75
|
//#region src/utils/diagnostics.ts
|
|
@@ -609,6 +610,141 @@ var PackageManager = class PackageManager {
|
|
|
609
610
|
}
|
|
610
611
|
};
|
|
611
612
|
|
|
613
|
+
//#endregion
|
|
614
|
+
//#region src/server/index.ts
|
|
615
|
+
async function startServer({ port, host, configPath, config, version: version$2, events, onGenerate }) {
|
|
616
|
+
const server = createServer(async (req, res) => {
|
|
617
|
+
function send(type, ...data) {
|
|
618
|
+
const event = {
|
|
619
|
+
type,
|
|
620
|
+
data,
|
|
621
|
+
timestamp: Date.now()
|
|
622
|
+
};
|
|
623
|
+
res.write(`data: ${JSON.stringify(event)}\n\n`);
|
|
624
|
+
}
|
|
625
|
+
events.on("plugin:start", (plugin) => send("plugin:start", plugin));
|
|
626
|
+
events.on("plugin:end", (plugin, meta) => send("plugin:end", plugin, meta));
|
|
627
|
+
events.on("files:processing:start", (files) => send("files:processing:start", { total: files.length }));
|
|
628
|
+
events.on("file:processing:update", (meta) => {
|
|
629
|
+
send("file:processing:update", {
|
|
630
|
+
file: meta.file.path,
|
|
631
|
+
processed: meta.processed,
|
|
632
|
+
total: meta.total,
|
|
633
|
+
percentage: meta.percentage
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
events.on("files:processing:end", (files) => send("files:processing:end", { total: files.length }));
|
|
637
|
+
events.on("info", (message, info) => send("info", message, info));
|
|
638
|
+
events.on("success", (message, info) => send("success", message, info));
|
|
639
|
+
events.on("warn", (message, info) => send("warn", message, info));
|
|
640
|
+
events.on("generation:start", (config$1) => {
|
|
641
|
+
send("generation:start", {
|
|
642
|
+
name: config$1.name,
|
|
643
|
+
plugins: config$1.plugins?.length || 0
|
|
644
|
+
});
|
|
645
|
+
});
|
|
646
|
+
events.on("generation:end", (config$1, files, sources) => {
|
|
647
|
+
const sourcesRecord = {};
|
|
648
|
+
sources.forEach((value, key) => {
|
|
649
|
+
sourcesRecord[key] = value;
|
|
650
|
+
});
|
|
651
|
+
send("generation:end", config$1, files, sourcesRecord);
|
|
652
|
+
});
|
|
653
|
+
events.on("error", (error) => {
|
|
654
|
+
send("error", {
|
|
655
|
+
message: error.message,
|
|
656
|
+
stack: error.stack
|
|
657
|
+
});
|
|
658
|
+
});
|
|
659
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
660
|
+
res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
|
|
661
|
+
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
|
|
662
|
+
if (req.method === "OPTIONS") {
|
|
663
|
+
res.writeHead(204);
|
|
664
|
+
res.end();
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
if (req.url === "/api/health" && req.method === "GET") {
|
|
668
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
669
|
+
const body = {
|
|
670
|
+
status: "ok",
|
|
671
|
+
version: version$2,
|
|
672
|
+
configPath: path.relative(process$1.cwd(), configPath)
|
|
673
|
+
};
|
|
674
|
+
res.end(JSON.stringify(body));
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
if (req.url === "/api/info" && req.method === "GET") {
|
|
678
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
679
|
+
let specContent;
|
|
680
|
+
if (config && "path" in config.input) {
|
|
681
|
+
const specPath = path.resolve(process$1.cwd(), config.root, config.input.path);
|
|
682
|
+
try {
|
|
683
|
+
specContent = readFileSync(specPath, "utf-8");
|
|
684
|
+
} catch {}
|
|
685
|
+
}
|
|
686
|
+
const body = {
|
|
687
|
+
version: version$2,
|
|
688
|
+
configPath: path.relative(process$1.cwd(), configPath),
|
|
689
|
+
spec: specContent,
|
|
690
|
+
config: {
|
|
691
|
+
name: config.name,
|
|
692
|
+
root: config.root,
|
|
693
|
+
input: { path: "path" in config.input ? config.input.path : void 0 },
|
|
694
|
+
output: {
|
|
695
|
+
path: config.output.path,
|
|
696
|
+
write: config.output.write,
|
|
697
|
+
extension: config.output.extension,
|
|
698
|
+
barrelType: config.output.barrelType
|
|
699
|
+
},
|
|
700
|
+
plugins: config.plugins?.map((plugin) => ({
|
|
701
|
+
name: `@kubb/${plugin.name}`,
|
|
702
|
+
options: serializePluginOptions(plugin.options)
|
|
703
|
+
}))
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
res.end(JSON.stringify(body));
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
if (req.url === "/api/generate" && req.method === "POST") {
|
|
710
|
+
try {
|
|
711
|
+
res.writeHead(200, {
|
|
712
|
+
"Content-Type": "text/event-stream",
|
|
713
|
+
"Cache-Control": "no-cache",
|
|
714
|
+
Connection: "keep-alive"
|
|
715
|
+
});
|
|
716
|
+
await onGenerate();
|
|
717
|
+
} catch (error) {
|
|
718
|
+
send("error", {
|
|
719
|
+
message: error instanceof Error ? error.message : "Unknown error",
|
|
720
|
+
stack: error instanceof Error ? error.stack : void 0
|
|
721
|
+
});
|
|
722
|
+
} finally {
|
|
723
|
+
send("lifecycle:end");
|
|
724
|
+
res.end();
|
|
725
|
+
}
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
729
|
+
res.end(JSON.stringify({ error: "Not found" }));
|
|
730
|
+
});
|
|
731
|
+
return new Promise((resolve$1) => {
|
|
732
|
+
server.listen(port, host, () => {
|
|
733
|
+
const address = server.address();
|
|
734
|
+
const serverUrl = `http://${host}:${typeof address === "object" && address ? address.port : port}`;
|
|
735
|
+
events.emit("server:start", serverUrl, path.relative(process$1.cwd(), configPath));
|
|
736
|
+
resolve$1(server);
|
|
737
|
+
});
|
|
738
|
+
process$1.on("SIGINT", () => {
|
|
739
|
+
events.emit("server:shutdown");
|
|
740
|
+
server.close(() => {
|
|
741
|
+
events.emit("server:stopped");
|
|
742
|
+
process$1.exit(0);
|
|
743
|
+
});
|
|
744
|
+
});
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
|
|
612
748
|
//#endregion
|
|
613
749
|
//#region src/types.ts
|
|
614
750
|
const LogLevel = {
|
|
@@ -621,5 +757,5 @@ const LogLevel = {
|
|
|
621
757
|
};
|
|
622
758
|
|
|
623
759
|
//#endregion
|
|
624
|
-
export { BaseGenerator, LogLevel, PackageManager, PluginManager, PromiseManager, build, build as default, defineConfig, defineLogger, definePlugin, getBarrelFiles, getMode, isInputPath, safeBuild, setup };
|
|
760
|
+
export { BaseGenerator, LogLevel, PackageManager, PluginManager, PromiseManager, build, build as default, defineConfig, defineLogger, definePlugin, getBarrelFiles, getMode, isInputPath, safeBuild, setup, startServer };
|
|
625
761
|
//# sourceMappingURL=index.js.map
|