@kubb/agent 4.24.1 → 4.25.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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +710 -381
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +8 -10
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +5 -5
- package/.output/server/node_modules/.nitro/jiti@2.5.1/dist/babel.cjs +246 -0
- package/.output/server/node_modules/.nitro/jiti@2.5.1/dist/jiti.cjs +1 -0
- package/.output/server/node_modules/.nitro/jiti@2.5.1/lib/jiti.mjs +22 -0
- package/.output/server/node_modules/.nitro/jiti@2.5.1/package.json +134 -0
- package/.output/server/package.json +2 -2
- package/README.md +113 -19
- package/package.json +5 -3
- package/.output/server/chunks/_/package.mjs +0 -4
- package/.output/server/chunks/_/package.mjs.map +0 -1
- package/.output/server/chunks/routes/api/generate.options.mjs +0 -31
- package/.output/server/chunks/routes/api/generate.options.mjs.map +0 -1
- package/.output/server/chunks/routes/api/generate.post.mjs +0 -120
- package/.output/server/chunks/routes/api/generate.post.mjs.map +0 -1
- package/.output/server/chunks/routes/api/info.get.mjs +0 -63
- package/.output/server/chunks/routes/api/info.get.mjs.map +0 -1
- /package/.output/server/node_modules/{jiti → .nitro/jiti@2.6.1}/dist/jiti.cjs +0 -0
- /package/.output/server/node_modules/{jiti → .nitro/jiti@2.6.1}/lib/jiti.mjs +0 -0
- /package/.output/server/node_modules/{jiti → .nitro/jiti@2.6.1}/package.json +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jiti",
|
|
3
|
+
"version": "2.5.1",
|
|
4
|
+
"description": "Runtime typescript and ESM support for Node.js",
|
|
5
|
+
"repository": "unjs/jiti",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./lib/jiti.d.mts",
|
|
12
|
+
"default": "./lib/jiti.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./lib/jiti.d.cts",
|
|
16
|
+
"default": "./lib/jiti.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"./register": {
|
|
20
|
+
"types": "./lib/jiti-register.d.mts",
|
|
21
|
+
"import": "./lib/jiti-register.mjs"
|
|
22
|
+
},
|
|
23
|
+
"./native": {
|
|
24
|
+
"types": "./lib/jiti.d.mts",
|
|
25
|
+
"import": "./lib/jiti-native.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"main": "./lib/jiti.cjs",
|
|
30
|
+
"module": "./lib/jiti.mjs",
|
|
31
|
+
"types": "./lib/jiti.d.cts",
|
|
32
|
+
"typesVersions": {
|
|
33
|
+
"*": {
|
|
34
|
+
"register": [
|
|
35
|
+
"./lib/jiti-register.d.mts"
|
|
36
|
+
],
|
|
37
|
+
"native": [
|
|
38
|
+
"./lib/jiti.d.mts"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"bin": {
|
|
43
|
+
"jiti": "./lib/jiti-cli.mjs"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"lib",
|
|
47
|
+
"dist",
|
|
48
|
+
"register.cjs"
|
|
49
|
+
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "pnpm clean && NODE_ENV=production pnpm webpack",
|
|
52
|
+
"clean": "rm -rf dist",
|
|
53
|
+
"dev": "pnpm clean && pnpm webpack --watch",
|
|
54
|
+
"jiti": "JITI_DEBUG=1 JITI_JSX=1 lib/jiti-cli.mjs",
|
|
55
|
+
"lint": "eslint . && prettier -c src lib test stubs",
|
|
56
|
+
"lint:fix": "eslint --fix . && prettier -w src lib test stubs",
|
|
57
|
+
"prepack": "pnpm build",
|
|
58
|
+
"release": "pnpm build && pnpm test && changelogen --release --push --publish",
|
|
59
|
+
"test": "pnpm lint && pnpm test:types && vitest run --coverage && pnpm test:node-register && pnpm test:bun && pnpm test:native",
|
|
60
|
+
"test:bun": "bun --bun test test/bun",
|
|
61
|
+
"test:native": "pnpm test:native:bun && pnpm test:native:node && pnpm test:native:deno",
|
|
62
|
+
"test:native:bun": "bun --bun test test/native/bun.test.ts",
|
|
63
|
+
"test:native:deno": "deno test -A --no-check test/native/deno.test.ts",
|
|
64
|
+
"test:native:node": "node --test --experimental-strip-types test/native/node.test.ts",
|
|
65
|
+
"test:node-register": "JITI_JSX=1 node --test test/node-register.test.mjs",
|
|
66
|
+
"test:types": "tsc --noEmit"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@babel/core": "^7.28.0",
|
|
70
|
+
"@babel/helper-module-imports": "^7.27.1",
|
|
71
|
+
"@babel/helper-module-transforms": "^7.27.3",
|
|
72
|
+
"@babel/helper-plugin-utils": "^7.27.1",
|
|
73
|
+
"@babel/helper-simple-access": "^7.27.1",
|
|
74
|
+
"@babel/plugin-proposal-decorators": "^7.28.0",
|
|
75
|
+
"@babel/plugin-syntax-class-properties": "^7.12.13",
|
|
76
|
+
"@babel/plugin-syntax-import-assertions": "^7.27.1",
|
|
77
|
+
"@babel/plugin-syntax-jsx": "^7.27.1",
|
|
78
|
+
"@babel/plugin-transform-export-namespace-from": "^7.27.1",
|
|
79
|
+
"@babel/plugin-transform-react-jsx": "^7.27.1",
|
|
80
|
+
"@babel/plugin-transform-typescript": "^7.28.0",
|
|
81
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
82
|
+
"@babel/template": "^7.27.2",
|
|
83
|
+
"@babel/traverse": "^7.28.0",
|
|
84
|
+
"@babel/types": "^7.28.1",
|
|
85
|
+
"@types/babel__core": "^7.20.5",
|
|
86
|
+
"@types/babel__helper-module-imports": "^7.18.3",
|
|
87
|
+
"@types/babel__helper-plugin-utils": "^7.10.3",
|
|
88
|
+
"@types/babel__template": "^7.4.4",
|
|
89
|
+
"@types/babel__traverse": "^7.20.7",
|
|
90
|
+
"@types/node": "^24.1.0",
|
|
91
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
92
|
+
"acorn": "^8.15.0",
|
|
93
|
+
"babel-plugin-parameter-decorator": "^1.0.16",
|
|
94
|
+
"changelogen": "^0.6.2",
|
|
95
|
+
"config": "^4.0.1",
|
|
96
|
+
"consola": "^3.4.2",
|
|
97
|
+
"defu": "^6.1.4",
|
|
98
|
+
"destr": "^2.0.5",
|
|
99
|
+
"escape-string-regexp": "^5.0.0",
|
|
100
|
+
"eslint": "^9.31.0",
|
|
101
|
+
"eslint-config-unjs": "^0.5.0",
|
|
102
|
+
"estree-walker": "^3.0.3",
|
|
103
|
+
"etag": "^1.8.1",
|
|
104
|
+
"fast-glob": "^3.3.3",
|
|
105
|
+
"is-installed-globally": "^1.0.0",
|
|
106
|
+
"mime": "^4.0.7",
|
|
107
|
+
"mlly": "^1.7.4",
|
|
108
|
+
"moment-timezone": "^0.6.0",
|
|
109
|
+
"nano-jsx": "^0.1.0",
|
|
110
|
+
"pathe": "^2.0.3",
|
|
111
|
+
"pkg-types": "^2.2.0",
|
|
112
|
+
"preact": "^10.26.9",
|
|
113
|
+
"preact-render-to-string": "^6.5.13",
|
|
114
|
+
"prettier": "^3.6.2",
|
|
115
|
+
"react": "^19.1.0",
|
|
116
|
+
"react-dom": "^19.1.0",
|
|
117
|
+
"reflect-metadata": "^0.2.2",
|
|
118
|
+
"solid-js": "^1.9.7",
|
|
119
|
+
"std-env": "^3.9.0",
|
|
120
|
+
"terser-webpack-plugin": "^5.3.14",
|
|
121
|
+
"tinyexec": "^1.0.1",
|
|
122
|
+
"ts-loader": "^9.5.2",
|
|
123
|
+
"typescript": "^5.8.3",
|
|
124
|
+
"vitest": "^3.2.4",
|
|
125
|
+
"vue": "^3.5.18",
|
|
126
|
+
"webpack": "^5.100.2",
|
|
127
|
+
"webpack-bundle-analyzer": "^4.10.2",
|
|
128
|
+
"webpack-cli": "^6.0.1",
|
|
129
|
+
"webpack-license-plugin": "^4.5.1",
|
|
130
|
+
"yoctocolors": "^2.1.1",
|
|
131
|
+
"zod": "^4.0.5"
|
|
132
|
+
},
|
|
133
|
+
"packageManager": "pnpm@10.6.1"
|
|
134
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/agent-prod",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.25.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": true,
|
|
6
6
|
"dependencies": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"is-stream": "4.0.1",
|
|
28
28
|
"is-unicode-supported": "2.1.0",
|
|
29
29
|
"isexe": "2.0.0",
|
|
30
|
-
"jiti": "2.
|
|
30
|
+
"jiti": "2.5.1",
|
|
31
31
|
"js-runtime": "0.0.8",
|
|
32
32
|
"jsonfile": "6.2.0",
|
|
33
33
|
"mime-db": "1.33.0",
|
package/README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# @kubb/agent
|
|
2
2
|
|
|
3
|
-
Kubb Agent Server — HTTP server for code generation powered by
|
|
3
|
+
Kubb Agent Server — HTTP server for code generation powered by [Nitro](https://nitro.build) with WebSocket integration for real-time Studio communication.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- 🚀 Fast HTTP server built with
|
|
7
|
+
- 🚀 Fast HTTP server built with [Nitro](https://nitro.build)
|
|
8
8
|
- 📡 RESTful API endpoints for code generation
|
|
9
9
|
- 🔧 Easy integration with Kubb configuration
|
|
10
10
|
- 📊 Health and info endpoints
|
|
11
|
+
- 🔗 Bidirectional WebSocket with Kubb Studio
|
|
12
|
+
- 💾 Automatic session caching for faster reconnects
|
|
11
13
|
- ⚡ Production-ready
|
|
12
14
|
|
|
13
15
|
## Installation
|
|
@@ -31,33 +33,131 @@ kubb agent start --config kubb.config.ts
|
|
|
31
33
|
With custom options:
|
|
32
34
|
|
|
33
35
|
```bash
|
|
34
|
-
kubb agent start --config kubb.config.ts --host 0.0.0.0 --port 8080
|
|
36
|
+
kubb agent start --config kubb.config.ts --host 0.0.0.0 --port 8080 --no-cache
|
|
35
37
|
```
|
|
36
38
|
|
|
37
39
|
### Manual Server Start
|
|
38
40
|
|
|
39
41
|
If you need to start the server directly:
|
|
40
42
|
|
|
41
|
-
```bash
|
|
42
|
-
KUBB_CONFIG=./kubb.config.ts node packages/agent/.output/server/index.mjs
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Or if using the built package:
|
|
46
|
-
|
|
47
43
|
```bash
|
|
48
44
|
KUBB_CONFIG=./kubb.config.ts node node_modules/@kubb/agent/.output/server/index.mjs
|
|
49
45
|
```
|
|
50
46
|
|
|
51
|
-
The server will be available at `http://localhost:
|
|
47
|
+
The server will be available at `http://localhost:4000`.
|
|
52
48
|
|
|
53
49
|
### Environment Variables
|
|
54
50
|
|
|
55
51
|
- `KUBB_CONFIG` - **Required**. Path to your Kubb configuration file (e.g., `./kubb.config.ts` or `./kubb.config.js`). Supports both TypeScript and JavaScript files. Can be relative or absolute.
|
|
56
|
-
- `PORT` - Server port (default: `
|
|
52
|
+
- `PORT` - Server port (default: `4000`)
|
|
57
53
|
- `HOST` - Server host (default: `localhost`)
|
|
54
|
+
- `KUBB_STUDIO_URL` - Studio connection URL (e.g., `http://localhost:3000`)
|
|
55
|
+
- `KUBB_AGENT_TOKEN` - Authentication token for Studio connection
|
|
56
|
+
- `KUBB_AGENT_NO_CACHE` - Disable session caching (set to `true` to skip cache)
|
|
57
|
+
|
|
58
|
+
### Automatic .env Loading
|
|
59
|
+
|
|
60
|
+
The agent automatically loads environment variables from:
|
|
61
|
+
1. `.env` - Base environment variables
|
|
62
|
+
2. `.env.local` - Local overrides (for secrets/local config)
|
|
63
|
+
|
|
64
|
+
Files are optional and loaded in order, with `.env.local` taking precedence.
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
1. **Create `.env` file:**
|
|
69
|
+
```env
|
|
70
|
+
PORT=4000
|
|
71
|
+
KUBB_ROOT=/Users/stijnvanhulle/GitHub/kubb/examples/react-query/
|
|
72
|
+
KUBB_CONFIG=/Users/stijnvanhulle/GitHub/kubb/examples/react-query/kubb.config.ts
|
|
73
|
+
KUBB_AGENT_TOKEN=
|
|
74
|
+
KUBB_AGENT_NO_CACHE=true
|
|
75
|
+
KUBB_STUDIO_URL=https://studio.kubb,dev
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
2. **Run the agent:**
|
|
79
|
+
```bash
|
|
80
|
+
npx kubb agent start
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
3. **Agent is now available at:**
|
|
84
|
+
```
|
|
85
|
+
http://localhost:4000
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## WebSocket Studio Integration
|
|
89
|
+
|
|
90
|
+
The agent automatically connects to Kubb Studio on startup:
|
|
91
|
+
|
|
92
|
+
### Connection Features
|
|
58
93
|
|
|
94
|
+
- **Automatic reconnection**: Caches session tokens to speed up reconnects
|
|
95
|
+
- **Real-time events**: Streams generation progress and events
|
|
96
|
+
- **Command handling**: Receives `generate` and `connect` commands from Studio
|
|
97
|
+
- **Graceful shutdown**: Notifies Studio when disconnecting
|
|
98
|
+
- **Session management**: 24-hour session expiration with auto-refresh
|
|
59
99
|
|
|
60
|
-
|
|
100
|
+
### Session Caching
|
|
101
|
+
|
|
102
|
+
Sessions are cached in `~/.kubb/config.json` for faster reconnects:
|
|
103
|
+
- Tokens are hashed (non-reversible) for security
|
|
104
|
+
- Sessions auto-expire after 24 hours
|
|
105
|
+
- Use `--no-cache` flag to disable caching
|
|
106
|
+
- Invalid sessions are automatically cleaned up
|
|
107
|
+
|
|
108
|
+
## WebSocket API
|
|
109
|
+
|
|
110
|
+
### Messages Sent by Agent
|
|
111
|
+
|
|
112
|
+
**Connected**
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"type": "connected",
|
|
116
|
+
"id": "unique-id",
|
|
117
|
+
"payload": {
|
|
118
|
+
"version": "4.24.0",
|
|
119
|
+
"config": { /* full kubb config */ },
|
|
120
|
+
"spec": "/* OpenAPI spec */"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Data Events (during generation)**
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"type": "data",
|
|
129
|
+
"id": "message-id",
|
|
130
|
+
"event": "plugin:start",
|
|
131
|
+
"payload": "{...}"
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Ping (every 30 seconds)**
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"type": "ping"
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Messages Received from Studio
|
|
143
|
+
|
|
144
|
+
**Generate Command**
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"type": "command",
|
|
148
|
+
"command": "generate"
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Connect Command (resend info)**
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"type": "command",
|
|
156
|
+
"command": "connect"
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Configuration Example
|
|
61
161
|
|
|
62
162
|
### 1. Create a Kubb configuration file (`kubb.config.ts`):
|
|
63
163
|
|
|
@@ -83,13 +183,7 @@ export default defineConfig({
|
|
|
83
183
|
### 2. Start the agent server:
|
|
84
184
|
|
|
85
185
|
```bash
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### 3. Trigger generation:
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
curl -N http://localhost:3000/api/generate
|
|
186
|
+
npx kubb agent start
|
|
93
187
|
```
|
|
94
188
|
|
|
95
189
|
You'll receive a stream of events as the code generation progresses.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/agent",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.25.1",
|
|
4
4
|
"description": "Agent server for Kubb, enabling HTTP-based access to code generation capabilities.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -40,12 +40,14 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@kubb/fabric-core": "0.12.11",
|
|
42
42
|
"execa": "^9.6.1",
|
|
43
|
-
"jiti": "
|
|
43
|
+
"jiti": "2.5.1",
|
|
44
44
|
"nitropack": "^2.13.1",
|
|
45
|
+
"picocolors": "^1.1.1",
|
|
45
46
|
"string-argv": "^0.3.2",
|
|
46
|
-
"@kubb/core": "4.
|
|
47
|
+
"@kubb/core": "4.25.1"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
50
|
+
"msw": "^2.6.10",
|
|
49
51
|
"vite": "^7.3.1"
|
|
50
52
|
},
|
|
51
53
|
"engines": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.mjs","sources":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { d as defineEventHandler } from '../../nitro/nitro.mjs';
|
|
2
|
-
import 'node:http';
|
|
3
|
-
import 'node:https';
|
|
4
|
-
import 'node:events';
|
|
5
|
-
import 'node:buffer';
|
|
6
|
-
import 'node:fs';
|
|
7
|
-
import 'node:path';
|
|
8
|
-
import 'node:crypto';
|
|
9
|
-
import 'node:perf_hooks';
|
|
10
|
-
import 'fs-extra';
|
|
11
|
-
import 'js-runtime';
|
|
12
|
-
import 'node:module';
|
|
13
|
-
import '@kubb/react-fabric';
|
|
14
|
-
import '@kubb/react-fabric/parsers';
|
|
15
|
-
import '@kubb/react-fabric/plugins';
|
|
16
|
-
import 'node:process';
|
|
17
|
-
import 'node:os';
|
|
18
|
-
import 'node:url';
|
|
19
|
-
import 'semver';
|
|
20
|
-
import 'natural-orderby';
|
|
21
|
-
import 'execa';
|
|
22
|
-
import 'string-argv';
|
|
23
|
-
import 'jiti';
|
|
24
|
-
import 'node:async_hooks';
|
|
25
|
-
|
|
26
|
-
const generate_options = defineEventHandler(() => {
|
|
27
|
-
return { ok: true };
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export { generate_options as default };
|
|
31
|
-
//# sourceMappingURL=generate.options.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.options.mjs","sources":["../../../../../server/routes/api/generate.options.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAA,mBAAA,MAAA;AAEA,EAAA,OAAA,EAAA,IAAA,IAAA,EAAA;AACA,CAAA,CAAA;;;;"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { d as defineEventHandler, u as useKubbAgentContext, s as setHeaders } from '../../nitro/nitro.mjs';
|
|
2
|
-
import 'node:http';
|
|
3
|
-
import 'node:https';
|
|
4
|
-
import 'node:events';
|
|
5
|
-
import 'node:buffer';
|
|
6
|
-
import 'node:fs';
|
|
7
|
-
import 'node:path';
|
|
8
|
-
import 'node:crypto';
|
|
9
|
-
import 'node:perf_hooks';
|
|
10
|
-
import 'fs-extra';
|
|
11
|
-
import 'js-runtime';
|
|
12
|
-
import 'node:module';
|
|
13
|
-
import '@kubb/react-fabric';
|
|
14
|
-
import '@kubb/react-fabric/parsers';
|
|
15
|
-
import '@kubb/react-fabric/plugins';
|
|
16
|
-
import 'node:process';
|
|
17
|
-
import 'node:os';
|
|
18
|
-
import 'node:url';
|
|
19
|
-
import 'semver';
|
|
20
|
-
import 'natural-orderby';
|
|
21
|
-
import 'execa';
|
|
22
|
-
import 'string-argv';
|
|
23
|
-
import 'jiti';
|
|
24
|
-
import 'node:async_hooks';
|
|
25
|
-
|
|
26
|
-
const generate_post = defineEventHandler(async (event) => {
|
|
27
|
-
const { events, onGenerate } = useKubbAgentContext();
|
|
28
|
-
setHeaders(event, {
|
|
29
|
-
"Content-Type": "text/event-stream",
|
|
30
|
-
"Cache-Control": "no-cache",
|
|
31
|
-
Connection: "keep-alive"
|
|
32
|
-
});
|
|
33
|
-
const stream = new ReadableStream({
|
|
34
|
-
start(controller) {
|
|
35
|
-
const queue = [];
|
|
36
|
-
let draining = false;
|
|
37
|
-
function send2(type, ...data) {
|
|
38
|
-
const sseEvent = { type, data, timestamp: Date.now() };
|
|
39
|
-
const message = `data: ${JSON.stringify(sseEvent)}
|
|
40
|
-
|
|
41
|
-
`;
|
|
42
|
-
queue.push(message);
|
|
43
|
-
drain();
|
|
44
|
-
}
|
|
45
|
-
async function drain() {
|
|
46
|
-
if (draining) return;
|
|
47
|
-
draining = true;
|
|
48
|
-
while (queue.length > 0) {
|
|
49
|
-
const message = queue.shift();
|
|
50
|
-
if (message) {
|
|
51
|
-
controller.enqueue(message);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
draining = false;
|
|
55
|
-
}
|
|
56
|
-
events.on("plugin:start", (plugin) => send2("plugin:start", plugin));
|
|
57
|
-
events.on("plugin:end", (plugin, meta) => send2("plugin:end", plugin, meta));
|
|
58
|
-
events.on("files:processing:start", (files) => send2("files:processing:start", { total: files.length }));
|
|
59
|
-
events.on("file:processing:update", (meta) => {
|
|
60
|
-
send2("file:processing:update", {
|
|
61
|
-
file: meta.file.path,
|
|
62
|
-
processed: meta.processed,
|
|
63
|
-
total: meta.total,
|
|
64
|
-
percentage: meta.percentage
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
events.on("files:processing:end", (files) => send2("files:processing:end", { total: files.length }));
|
|
68
|
-
events.on("info", (message, info) => send2("info", message, info));
|
|
69
|
-
events.on("success", (message, info) => send2("success", message, info));
|
|
70
|
-
events.on("warn", (message, info) => send2("warn", message, info));
|
|
71
|
-
events.on("generation:start", (config) => {
|
|
72
|
-
var _a;
|
|
73
|
-
send2("generation:start", {
|
|
74
|
-
name: config.name,
|
|
75
|
-
plugins: ((_a = config.plugins) == null ? void 0 : _a.length) || 0
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
events.on("generation:end", (config, files, sources) => {
|
|
79
|
-
const sourcesRecord = {};
|
|
80
|
-
sources.forEach((value, key) => {
|
|
81
|
-
sourcesRecord[key] = value;
|
|
82
|
-
});
|
|
83
|
-
send2("generation:end", config, files, sourcesRecord);
|
|
84
|
-
});
|
|
85
|
-
events.on("error", (error) => {
|
|
86
|
-
send2("error", {
|
|
87
|
-
message: error.message,
|
|
88
|
-
stack: error.stack
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
onGenerate().catch((error) => {
|
|
92
|
-
const sseEvent = {
|
|
93
|
-
type: "error",
|
|
94
|
-
data: [
|
|
95
|
-
{
|
|
96
|
-
message: error instanceof Error ? error.message : "Unknown error",
|
|
97
|
-
stack: error instanceof Error ? error.stack : void 0
|
|
98
|
-
}
|
|
99
|
-
],
|
|
100
|
-
timestamp: Date.now()
|
|
101
|
-
};
|
|
102
|
-
queue.push(`data: ${JSON.stringify(sseEvent)}
|
|
103
|
-
|
|
104
|
-
`);
|
|
105
|
-
}).finally(() => {
|
|
106
|
-
const endEvent = { type: "lifecycle:end", data: [], timestamp: Date.now() };
|
|
107
|
-
queue.push(`data: ${JSON.stringify(endEvent)}
|
|
108
|
-
|
|
109
|
-
`);
|
|
110
|
-
drain().then(() => {
|
|
111
|
-
controller.close();
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
return stream;
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
export { generate_post as default };
|
|
120
|
-
//# sourceMappingURL=generate.post.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.post.mjs","sources":["../../../../../server/routes/api/generate.post.ts"],"names":["send"],"mappings":";;;;;;;;;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A,CAAA,CAAA,MAAA,EAAA,IAAA,CAAA,SAAA,CAAA,QAAA,CAAA;;AAAA,CAAA,CAAA;AACA,QAAA,KAAA,EAAA,CAAA,KAAA,MAAA;AACA,UAAA,UAAA,CAAA,KAAA,EAAA;AAAA,QACA,CAAA,CAAA;AAAA,MACA,CAAA,CAAA;AAAA,IACA;AAAA,GACA,CAAA;AAEA,EAAA,OAAA,MAAA;AACA,CAAA,CAAA;;;;"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { d as defineEventHandler, u as useKubbAgentContext, a as serializePluginOptions } from '../../nitro/nitro.mjs';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import process from 'node:process';
|
|
5
|
-
import { v as version } from '../../_/package.mjs';
|
|
6
|
-
import 'node:http';
|
|
7
|
-
import 'node:https';
|
|
8
|
-
import 'node:events';
|
|
9
|
-
import 'node:buffer';
|
|
10
|
-
import 'node:crypto';
|
|
11
|
-
import 'node:perf_hooks';
|
|
12
|
-
import 'fs-extra';
|
|
13
|
-
import 'js-runtime';
|
|
14
|
-
import 'node:module';
|
|
15
|
-
import '@kubb/react-fabric';
|
|
16
|
-
import '@kubb/react-fabric/parsers';
|
|
17
|
-
import '@kubb/react-fabric/plugins';
|
|
18
|
-
import 'node:os';
|
|
19
|
-
import 'node:url';
|
|
20
|
-
import 'semver';
|
|
21
|
-
import 'natural-orderby';
|
|
22
|
-
import 'execa';
|
|
23
|
-
import 'string-argv';
|
|
24
|
-
import 'jiti';
|
|
25
|
-
import 'node:async_hooks';
|
|
26
|
-
|
|
27
|
-
const info_get = defineEventHandler(async () => {
|
|
28
|
-
var _a;
|
|
29
|
-
const { config } = useKubbAgentContext();
|
|
30
|
-
let specContent;
|
|
31
|
-
if (config && "path" in config.input) {
|
|
32
|
-
const specPath = path.resolve(process.cwd(), config.root, config.input.path);
|
|
33
|
-
try {
|
|
34
|
-
specContent = readFileSync(specPath, "utf-8");
|
|
35
|
-
} catch {
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
version,
|
|
40
|
-
configPath: process.env.KUBB_CONFIG || "",
|
|
41
|
-
spec: specContent,
|
|
42
|
-
config: {
|
|
43
|
-
name: config.name,
|
|
44
|
-
root: config.root,
|
|
45
|
-
input: {
|
|
46
|
-
path: "path" in config.input ? config.input.path : void 0
|
|
47
|
-
},
|
|
48
|
-
output: {
|
|
49
|
-
path: config.output.path,
|
|
50
|
-
write: config.output.write,
|
|
51
|
-
extension: config.output.extension,
|
|
52
|
-
barrelType: config.output.barrelType
|
|
53
|
-
},
|
|
54
|
-
plugins: (_a = config.plugins) == null ? void 0 : _a.map((plugin) => ({
|
|
55
|
-
name: `@kubb/${plugin.name}`,
|
|
56
|
-
options: serializePluginOptions(plugin.options)
|
|
57
|
-
}))
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export { info_get as default };
|
|
63
|
-
//# sourceMappingURL=info.get.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"info.get.mjs","sources":["../../../../../server/routes/api/info.get.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,iBAAA,mBAAA,YAAA;;AACA,EAAA,MAAA,EAAA,MAAA,EAAA,GAAA,mBAAA,EAAA;AAGA,EAAA,IAAA,WAAA;AACA,EAAA,IAAA,MAAA,IAAA,MAAA,IAAA,MAAA,CAAA,KAAA,EAAA;AACA,IAAA,MAAA,QAAA,GAAA,IAAA,CAAA,OAAA,CAAA,OAAA,CAAA,GAAA,IAAA,MAAA,CAAA,IAAA,EAAA,MAAA,CAAA,KAAA,CAAA,IAAA,CAAA;AACA,IAAA,IAAA;AACA,MAAA,WAAA,GAAA,YAAA,CAAA,UAAA,OAAA,CAAA;AAAA,IACA,CAAA,CAAA,MAAA;AAAA,IAEA;AAAA,EACA;AAEA,EAAA,OAAA;AAAA,IACA,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