@kubb/cli 5.0.0-beta.9 → 5.0.0-beta.91
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/LICENSE +17 -10
- package/README.md +48 -79
- package/bin/kubb.js +9 -3
- package/dist/Telemetry-7z2tIqPm.js +282 -0
- package/dist/Telemetry-7z2tIqPm.js.map +1 -0
- package/dist/{telemetry-B2iWkY5e.cjs → Telemetry-xcWb-UWT.cjs} +167 -116
- package/dist/Telemetry-xcWb-UWT.cjs.map +1 -0
- package/dist/{errors-CINO1EIv.js → errors-CMvLO2NE.js} +3 -15
- package/dist/{errors-CINO1EIv.js.map → errors-CMvLO2NE.js.map} +1 -1
- package/dist/{errors-CLCjoSg0.cjs → errors-DNxBUo3k.cjs} +2 -20
- package/dist/{errors-CLCjoSg0.cjs.map → errors-DNxBUo3k.cjs.map} +1 -1
- package/dist/generate-C9fJvlhv.js +87 -0
- package/dist/generate-C9fJvlhv.js.map +1 -0
- package/dist/generate-CIVRaeeA.cjs +87 -0
- package/dist/generate-CIVRaeeA.cjs.map +1 -0
- package/dist/index.cjs +33 -261
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +34 -262
- package/dist/index.js.map +1 -1
- package/dist/{init-bKtEOvhK.cjs → init-BBmle7Oc.cjs} +12 -13
- package/dist/init-BBmle7Oc.cjs.map +1 -0
- package/dist/{init-DOSXtcyb.js → init-DXjubhO6.js} +13 -13
- package/dist/init-DXjubhO6.js.map +1 -0
- package/dist/mcp-DLKKD_8s.js +21 -0
- package/dist/mcp-DLKKD_8s.js.map +1 -0
- package/dist/mcp-Dzgpeor_.cjs +20 -0
- package/dist/mcp-Dzgpeor_.cjs.map +1 -0
- package/dist/{package-DHGhrRW-.cjs → package-Bsc6NeTU.cjs} +2 -2
- package/dist/package-Bsc6NeTU.cjs.map +1 -0
- package/dist/package-CaBsNdoM.js +6 -0
- package/dist/package-CaBsNdoM.js.map +1 -0
- package/dist/{chunk-BvFE5Tac.js → rolldown-runtime-C0LytTxp.js} +0 -1
- package/dist/run-BBS4Sc38.js +1256 -0
- package/dist/run-BBS4Sc38.js.map +1 -0
- package/dist/{run-YsoCk5we.cjs → run-BNOCBw2y.cjs} +152 -98
- package/dist/run-BNOCBw2y.cjs.map +1 -0
- package/dist/{run-CQbj3ley.cjs → run-BdtVrLKu.cjs} +9 -15
- package/dist/run-BdtVrLKu.cjs.map +1 -0
- package/dist/run-Bgn3IPJt.cjs +1259 -0
- package/dist/run-Bgn3IPJt.cjs.map +1 -0
- package/dist/{run-CF97BWVa.js → run-CINOocLR.js} +138 -84
- package/dist/run-CINOocLR.js.map +1 -0
- package/dist/{run-CCZ24VKk.js → run-CaOjZRiQ.js} +7 -13
- package/dist/run-CaOjZRiQ.js.map +1 -0
- package/dist/run-D2vd34xp.cjs +33 -0
- package/dist/run-D2vd34xp.cjs.map +1 -0
- package/dist/run-lgrTO14E.js +32 -0
- package/dist/run-lgrTO14E.js.map +1 -0
- package/dist/tools-B23ltmWP.js +152 -0
- package/dist/tools-B23ltmWP.js.map +1 -0
- package/dist/tools-CeIABV0T.cjs +175 -0
- package/dist/tools-CeIABV0T.cjs.map +1 -0
- package/dist/{validate-Bj8vbvPt.cjs → validate-DaxZu9c3.cjs} +9 -10
- package/dist/validate-DaxZu9c3.cjs.map +1 -0
- package/dist/{validate-bHUrnYBv.js → validate-ugxFStuH.js} +10 -10
- package/dist/validate-ugxFStuH.js.map +1 -0
- package/package.json +14 -28
- package/dist/agent-C5F4itrc.js +0 -68
- package/dist/agent-C5F4itrc.js.map +0 -1
- package/dist/agent-d-lmeOr1.cjs +0 -70
- package/dist/agent-d-lmeOr1.cjs.map +0 -1
- package/dist/constants-B2JTeRBb.js +0 -42
- package/dist/constants-B2JTeRBb.js.map +0 -1
- package/dist/constants-BINTA5VZ.cjs +0 -77
- package/dist/constants-BINTA5VZ.cjs.map +0 -1
- package/dist/constants-BYGmiFs0.cjs +0 -139
- package/dist/constants-BYGmiFs0.cjs.map +0 -1
- package/dist/constants-DSJ-Xrbv.js +0 -116
- package/dist/constants-DSJ-Xrbv.js.map +0 -1
- package/dist/define-Bdn8j5VM.cjs +0 -54
- package/dist/define-Bdn8j5VM.cjs.map +0 -1
- package/dist/define-m_fp-Aqm.js +0 -43
- package/dist/define-m_fp-Aqm.js.map +0 -1
- package/dist/generate-BhfRufgh.js +0 -72
- package/dist/generate-BhfRufgh.js.map +0 -1
- package/dist/generate-BvuSxNYj.cjs +0 -71
- package/dist/generate-BvuSxNYj.cjs.map +0 -1
- package/dist/init-DOSXtcyb.js.map +0 -1
- package/dist/init-bKtEOvhK.cjs.map +0 -1
- package/dist/mcp-CKkbG0kp.cjs +0 -39
- package/dist/mcp-CKkbG0kp.cjs.map +0 -1
- package/dist/mcp-DzOfqX_j.js +0 -39
- package/dist/mcp-DzOfqX_j.js.map +0 -1
- package/dist/package-BgAYWN7y.js +0 -6
- package/dist/package-BgAYWN7y.js.map +0 -1
- package/dist/package-DHGhrRW-.cjs.map +0 -1
- package/dist/run-BObDb2qe.cjs +0 -1741
- package/dist/run-BObDb2qe.cjs.map +0 -1
- package/dist/run-BzpYYOQs.js +0 -121
- package/dist/run-BzpYYOQs.js.map +0 -1
- package/dist/run-CCZ24VKk.js.map +0 -1
- package/dist/run-CF97BWVa.js.map +0 -1
- package/dist/run-CQbj3ley.cjs.map +0 -1
- package/dist/run-D0hmRpHy.js +0 -49
- package/dist/run-D0hmRpHy.js.map +0 -1
- package/dist/run-DwdAwnLG.cjs +0 -125
- package/dist/run-DwdAwnLG.cjs.map +0 -1
- package/dist/run-Lr0Ctnu0.cjs +0 -50
- package/dist/run-Lr0Ctnu0.cjs.map +0 -1
- package/dist/run-P6D8TnXf.js +0 -1738
- package/dist/run-P6D8TnXf.js.map +0 -1
- package/dist/run-YsoCk5we.cjs.map +0 -1
- package/dist/shell-475fQKaX.cjs +0 -62
- package/dist/shell-475fQKaX.cjs.map +0 -1
- package/dist/shell-CN6DNqeC.js +0 -51
- package/dist/shell-CN6DNqeC.js.map +0 -1
- package/dist/telemetry-B2iWkY5e.cjs.map +0 -1
- package/dist/telemetry-BkektVz6.js +0 -243
- package/dist/telemetry-BkektVz6.js.map +0 -1
- package/dist/validate-Bj8vbvPt.cjs.map +0 -1
- package/dist/validate-bHUrnYBv.js.map +0 -1
- package/src/commands/agent/start.ts +0 -50
- package/src/commands/agent.ts +0 -10
- package/src/commands/generate.ts +0 -59
- package/src/commands/init.ts +0 -51
- package/src/commands/mcp.ts +0 -36
- package/src/commands/validate.ts +0 -22
- package/src/constants.ts +0 -48
- package/src/index.ts +0 -45
- package/src/loggers/clackLogger.ts +0 -460
- package/src/loggers/fileSystemLogger.ts +0 -151
- package/src/loggers/githubActionsLogger.ts +0 -367
- package/src/loggers/plainLogger.ts +0 -243
- package/src/loggers/types.ts +0 -7
- package/src/loggers/utils.ts +0 -252
- package/src/runners/agent/run.ts +0 -113
- package/src/runners/agent/utils.ts +0 -98
- package/src/runners/generate/run.ts +0 -276
- package/src/runners/generate/utils.ts +0 -209
- package/src/runners/init/run.ts +0 -211
- package/src/runners/init/utils.ts +0 -33
- package/src/runners/mcp/run.ts +0 -55
- package/src/runners/validate/run.ts +0 -63
- package/src/telemetry.ts +0 -280
- /package/dist/{chunk-ByKO4r7w.cjs → rolldown-runtime-Bx3C2hgW.cjs} +0 -0
package/LICENSE
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
This repository contains software under two licenses:
|
|
1
|
+
MIT License
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
MIT License — see licenses/LICENSE-MIT for the full license text.
|
|
3
|
+
Copyright (c) 2026 Stijn Van Hulle
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<h1>@kubb/cli</h1>
|
|
3
2
|
<a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
|
|
4
|
-
<img
|
|
3
|
+
<img src="https://kubb.dev/og.png" alt="Kubb banner">
|
|
5
4
|
</a>
|
|
6
5
|
|
|
7
6
|
[![npm version][npm-version-src]][npm-version-href]
|
|
8
7
|
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
9
|
-
[![
|
|
8
|
+
[![Stars][stars-src]][stars-href]
|
|
10
9
|
[![License][license-src]][license-href]
|
|
11
|
-
[![
|
|
10
|
+
[![Node][node-src]][node-href]
|
|
12
11
|
|
|
13
12
|
<h4>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
|
|
21
|
-
</h4>
|
|
13
|
+
<a href="https://kubb.dev" target="_blank">Documentation</a>
|
|
14
|
+
<span> · </span>
|
|
15
|
+
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
|
|
16
|
+
<span> · </span>
|
|
17
|
+
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
|
|
18
|
+
</h4>
|
|
22
19
|
</div>
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
<br />
|
|
22
|
+
|
|
23
|
+
# @kubb/cli
|
|
24
|
+
|
|
25
|
+
### The command-line interface for Kubb
|
|
26
|
+
|
|
27
|
+
Official CLI for Kubb. Run `kubb generate` to produce TypeScript types, API clients, hooks, validators, and mocks.
|
|
28
|
+
Includes interactive project setup (`kubb init`), spec validation, watch mode, and an MCP server.
|
|
25
29
|
|
|
26
30
|
## Installation
|
|
27
31
|
|
|
@@ -39,7 +43,6 @@ npm install -D @kubb/cli
|
|
|
39
43
|
- [`kubb generate`](#kubb-generate) — run code generation
|
|
40
44
|
- [`kubb validate`](#kubb-validate) — validate an OpenAPI spec
|
|
41
45
|
- [`kubb mcp`](#kubb-mcp) — start the MCP server for AI assistants
|
|
42
|
-
- [`kubb agent start`](#kubb-agent-start) — start the HTTP agent server
|
|
43
46
|
|
|
44
47
|
---
|
|
45
48
|
|
|
@@ -60,7 +63,7 @@ npx kubb init
|
|
|
60
63
|
| `--output <path>` | `-o` | string | `./src/gen` | Output directory for generated files |
|
|
61
64
|
| `--plugins <list>` | | string | | Comma-separated list of plugins to install |
|
|
62
65
|
|
|
63
|
-
Available plugin values for `--plugins`: `plugin-ts`, `plugin-
|
|
66
|
+
Available plugin values for `--plugins`: `plugin-ts`, `plugin-axios`, `plugin-fetch`, `plugin-react-query`, `plugin-vue-query`, `plugin-zod`, `plugin-faker`, `plugin-msw`, `plugin-cypress`, `plugin-mcp`, `plugin-redoc`.
|
|
64
67
|
|
|
65
68
|
#### Examples
|
|
66
69
|
|
|
@@ -75,7 +78,7 @@ npx kubb init --yes
|
|
|
75
78
|
npx kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod
|
|
76
79
|
|
|
77
80
|
# Select specific plugins only
|
|
78
|
-
npx kubb init --plugins plugin-ts,plugin-
|
|
81
|
+
npx kubb init --plugins plugin-ts,plugin-axios,plugin-react-query
|
|
79
82
|
```
|
|
80
83
|
|
|
81
84
|
The wizard will:
|
|
@@ -99,15 +102,15 @@ npx kubb generate
|
|
|
99
102
|
|
|
100
103
|
#### Options
|
|
101
104
|
|
|
102
|
-
| Flag | Short | Type | Default | Description
|
|
103
|
-
| -------------------- | ----- | ------- | ------- |
|
|
104
|
-
| `[input]` | | string | | OpenAPI file path
|
|
105
|
-
| `--config <path>` | `-c` | string | | Path to the Kubb config file
|
|
106
|
-
| `--logLevel <level>` | `-l` | string | `info` | Log level: `silent`, `info`,
|
|
107
|
-
| `--watch` | `-w` | boolean | `false` | Re-generate whenever the input file changes
|
|
108
|
-
| `--
|
|
109
|
-
| `--
|
|
110
|
-
| `--
|
|
105
|
+
| Flag | Short | Type | Default | Description |
|
|
106
|
+
| -------------------- | ----- | ------- | ------- | --------------------------------------------------------------------------------------------------- |
|
|
107
|
+
| `[input]` | | string | | OpenAPI file path or URL that overrides `input` in the config |
|
|
108
|
+
| `--config <path>` | `-c` | string | | Path to the Kubb config file |
|
|
109
|
+
| `--logLevel <level>` | `-l` | string | `info` | Log level: `silent`, `info`, or `verbose` |
|
|
110
|
+
| `--watch` | `-w` | boolean | `false` | Re-generate whenever the input file changes |
|
|
111
|
+
| `--verbose` | `-v` | boolean | `false` | Override log level to `verbose` |
|
|
112
|
+
| `--silent` | `-s` | boolean | `false` | Override log level to `silent` |
|
|
113
|
+
| `--reporter <names>` | | string | `cli` | Reporters that render the run, comma-separated: `cli`, `json`, `file`. Overrides `config.reporters` |
|
|
111
114
|
|
|
112
115
|
#### Examples
|
|
113
116
|
|
|
@@ -124,8 +127,11 @@ npx kubb generate --config ./configs/kubb.config.ts
|
|
|
124
127
|
# Watch for changes and regenerate automatically
|
|
125
128
|
npx kubb generate --watch
|
|
126
129
|
|
|
127
|
-
#
|
|
128
|
-
npx kubb generate --
|
|
130
|
+
# Verbose output
|
|
131
|
+
npx kubb generate --verbose
|
|
132
|
+
|
|
133
|
+
# Write a JSON run report alongside the CLI output
|
|
134
|
+
npx kubb generate --reporter cli,json
|
|
129
135
|
```
|
|
130
136
|
|
|
131
137
|
---
|
|
@@ -198,49 +204,12 @@ Add the following to your MCP client config (e.g. Claude Desktop's `claude_deskt
|
|
|
198
204
|
}
|
|
199
205
|
```
|
|
200
206
|
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
### `kubb agent start`
|
|
204
|
-
|
|
205
|
-
Start the Kubb Agent HTTP server. Exposes a REST API that accepts a `kubb.config.ts` patch and returns generated code as a stream. Use `--allow-write` to also write files to disk.
|
|
206
|
-
|
|
207
|
-
```bash
|
|
208
|
-
npx kubb agent start
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
#### Options
|
|
212
|
-
|
|
213
|
-
| Flag | Short | Type | Default | Description |
|
|
214
|
-
| ------------------- | ----- | ------- | --------- | ----------------------------------------------------------------- |
|
|
215
|
-
| `--config <path>` | `-c` | string | | Path to the Kubb config file |
|
|
216
|
-
| `--port <number>` | `-p` | string | `3000` | Port the HTTP server listens on |
|
|
217
|
-
| `--host <hostname>` | | string | `0.0.0.0` | Hostname the HTTP server binds to |
|
|
218
|
-
| `--allow-write` | | boolean | `false` | Write generated files to disk (otherwise output is streamed only) |
|
|
219
|
-
| `--allow-all` | | boolean | `false` | Grant all permissions (implies `--allow-write`) |
|
|
220
|
-
|
|
221
|
-
#### Examples
|
|
222
|
-
|
|
223
|
-
```bash
|
|
224
|
-
# Start with defaults
|
|
225
|
-
npx kubb agent start
|
|
226
|
-
|
|
227
|
-
# Custom port
|
|
228
|
-
npx kubb agent start --port 4000
|
|
229
|
-
|
|
230
|
-
# Allow writing files to disk
|
|
231
|
-
npx kubb agent start --allow-write
|
|
232
|
-
|
|
233
|
-
# Full permissions with custom config
|
|
234
|
-
npx kubb agent start --config ./kubb.config.ts --allow-all
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
See the [`@kubb/agent` README](../agent/README.md) for full environment variable reference, Docker setup, WebSocket API, and Studio integration.
|
|
238
|
-
|
|
239
207
|
## Supporting Kubb
|
|
240
208
|
|
|
241
|
-
Kubb
|
|
209
|
+
Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
|
|
242
210
|
|
|
243
211
|
- [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
|
|
212
|
+
- [See sponsorship tiers and our sponsors](https://kubb.dev/sponsors)
|
|
244
213
|
|
|
245
214
|
<p align="center">
|
|
246
215
|
<a href="https://github.com/sponsors/stijnvanhulle">
|
|
@@ -248,19 +217,19 @@ Kubb uses an MIT-licensed open source project with its ongoing development made
|
|
|
248
217
|
</a>
|
|
249
218
|
</p>
|
|
250
219
|
|
|
220
|
+
## License
|
|
221
|
+
|
|
222
|
+
[MIT](https://github.com/kubb-labs/kubb/blob/main/licenses/LICENSE-MIT)
|
|
223
|
+
|
|
251
224
|
<!-- Badges -->
|
|
252
225
|
|
|
253
|
-
[npm-version-src]: https://
|
|
254
|
-
[npm-version-href]: https://
|
|
255
|
-
[npm-downloads-src]: https://
|
|
256
|
-
[npm-downloads-href]: https://
|
|
257
|
-
[
|
|
226
|
+
[npm-version-src]: https://shieldcn.dev/npm/v/@kubb/cli.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
227
|
+
[npm-version-href]: https://npmx.dev/package/@kubb/cli
|
|
228
|
+
[npm-downloads-src]: https://shieldcn.dev/npm/dm/@kubb/cli.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
229
|
+
[npm-downloads-href]: https://npmx.dev/package/@kubb/cli
|
|
230
|
+
[stars-src]: https://shieldcn.dev/github/stars/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
231
|
+
[stars-href]: https://github.com/kubb-labs/kubb
|
|
232
|
+
[license-src]: https://shieldcn.dev/npm/license/@kubb/cli.svg?variant=secondary&size=xs&theme=zinc
|
|
258
233
|
[license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
|
|
259
|
-
[
|
|
260
|
-
[
|
|
261
|
-
[minified-src]: https://img.shields.io/bundlephobia/min/@kubb/cli?style=flat&colorA=18181B&colorB=f58517
|
|
262
|
-
[minified-href]: https://www.npmjs.com/package/@kubb/cli
|
|
263
|
-
[coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517
|
|
264
|
-
[coverage-href]: https://www.npmjs.com/package/@kubb/cli
|
|
265
|
-
[sponsors-src]: https://img.shields.io/github/sponsors/stijnvanhulle?style=flat&colorA=18181B&colorB=f58517
|
|
266
|
-
[sponsors-href]: https://github.com/sponsors/stijnvanhulle/
|
|
234
|
+
[node-src]: https://shieldcn.dev/npm/node/@kubb/cli.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
235
|
+
[node-href]: https://npmx.dev/package/@kubb/cli
|
package/bin/kubb.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
process.setSourceMapsEnabled?.(true)
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
process.setSourceMapsEnabled?.(true)
|
|
5
4
|
process.title = 'Kubb'
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
const { run } = await import('../dist/index.js')
|
|
8
|
+
await run(process.argv)
|
|
9
|
+
} catch (err) {
|
|
10
|
+
console.error(err)
|
|
11
|
+
process.exit(1)
|
|
12
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { randomBytes } from "node:crypto";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import process$1 from "node:process";
|
|
5
|
+
//#region ../../internals/utils/src/env.ts
|
|
6
|
+
/**
|
|
7
|
+
* Returns `true` when the process is running in a CI environment.
|
|
8
|
+
* Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,
|
|
9
|
+
* TeamCity, Buildkite, and Azure Pipelines.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* if (isCIEnvironment()) {
|
|
14
|
+
* logger.level = 'error'
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function isCIEnvironment() {
|
|
19
|
+
return !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.BITBUCKET_BUILD_NUMBER || process.env.JENKINS_URL || process.env.CIRCLECI || process.env.TRAVIS || process.env.TEAMCITY_VERSION || process.env.BUILDKITE || process.env.TF_BUILD);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns `true` when the process has an interactive TTY with a valid terminal
|
|
23
|
+
* width and is not running in CI.
|
|
24
|
+
*
|
|
25
|
+
* Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,
|
|
26
|
+
* which breaks clack's box-drawing helpers (they call `String.prototype.repeat`
|
|
27
|
+
* with a negative count and throw a `RangeError`). We therefore require a
|
|
28
|
+
* positive column count before declaring the TTY usable.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* if (canUseTTY()) {
|
|
33
|
+
* renderProgressBar()
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function canUseTTY() {
|
|
38
|
+
return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment();
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region ../../internals/utils/src/runtime.ts
|
|
42
|
+
/**
|
|
43
|
+
* Detects the JavaScript runtime executing the current process and exposes its name and version.
|
|
44
|
+
*
|
|
45
|
+
* Prefer the shared {@link runtime} instance over constructing your own.
|
|
46
|
+
*/
|
|
47
|
+
var Runtime = class {
|
|
48
|
+
/**
|
|
49
|
+
* `true` when the current process is running under Bun.
|
|
50
|
+
*
|
|
51
|
+
* Detection keys off the global `Bun` object rather than `process.versions`,
|
|
52
|
+
* because Bun polyfills `process.versions.node` for Node compatibility and would
|
|
53
|
+
* otherwise look like Node.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* if (runtime.isBun) {
|
|
58
|
+
* await Bun.write(path, data)
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
get isBun() {
|
|
63
|
+
return typeof Bun !== "undefined";
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* `true` when the current process is running under Deno.
|
|
67
|
+
*/
|
|
68
|
+
get isDeno() {
|
|
69
|
+
return typeof globalThis.Deno !== "undefined";
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* `true` when the current process is running under Node.
|
|
73
|
+
*
|
|
74
|
+
* Bun and Deno are excluded first so a polyfilled `process` does not register as Node.
|
|
75
|
+
*/
|
|
76
|
+
get isNode() {
|
|
77
|
+
return !this.isBun && !this.isDeno && typeof process !== "undefined" && process.versions?.node != null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Name of the runtime executing the current process.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
get name() {
|
|
88
|
+
if (this.isBun) return "bun";
|
|
89
|
+
if (this.isDeno) return "deno";
|
|
90
|
+
return "node";
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Version of the active runtime, or an empty string when it cannot be read.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* runtime.version // '1.3.11' under Bun, '22.22.2' under Node
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
get version() {
|
|
101
|
+
if (this.isBun) return process.versions.bun ?? "";
|
|
102
|
+
if (this.isDeno) return globalThis.Deno?.version?.deno ?? "";
|
|
103
|
+
return process.versions?.node ?? "";
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.
|
|
108
|
+
*/
|
|
109
|
+
const runtime = new Runtime();
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/constants.ts
|
|
112
|
+
/**
|
|
113
|
+
* NPM registry endpoint used to check for @kubb/cli updates.
|
|
114
|
+
*/
|
|
115
|
+
const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
|
|
116
|
+
/**
|
|
117
|
+
* OpenTelemetry ingestion endpoint for anonymous usage telemetry.
|
|
118
|
+
*/
|
|
119
|
+
const OTLP_ENDPOINT = "https://otlp.kubb.dev";
|
|
120
|
+
/**
|
|
121
|
+
* Glob pattern for paths the file watcher ignores.
|
|
122
|
+
*/
|
|
123
|
+
const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
|
|
124
|
+
/**
|
|
125
|
+
* Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run.
|
|
126
|
+
*/
|
|
127
|
+
const UPDATE_CHECK_TIMEOUT_MS = 3e3;
|
|
128
|
+
/**
|
|
129
|
+
* Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.
|
|
130
|
+
*/
|
|
131
|
+
const QUIET_FLAGS = /* @__PURE__ */ new Set([
|
|
132
|
+
"--help",
|
|
133
|
+
"-h",
|
|
134
|
+
"--version",
|
|
135
|
+
"-v"
|
|
136
|
+
]);
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/Telemetry.ts
|
|
139
|
+
/**
|
|
140
|
+
* Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
|
|
141
|
+
*/
|
|
142
|
+
function isDisabled() {
|
|
143
|
+
return process$1.env["DO_NOT_TRACK"] === "1" || process$1.env["DO_NOT_TRACK"] === "true" || process$1.env["KUBB_DISABLE_TELEMETRY"] === "1" || process$1.env["KUBB_DISABLE_TELEMETRY"] === "true";
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Build an anonymous telemetry payload from a completed generation run.
|
|
147
|
+
*/
|
|
148
|
+
function buildTelemetryEvent(options) {
|
|
149
|
+
const [seconds, nanoseconds] = process$1.hrtime(options.hrStart);
|
|
150
|
+
const duration = Math.round(seconds * 1e3 + nanoseconds / 1e6);
|
|
151
|
+
return {
|
|
152
|
+
command: options.command,
|
|
153
|
+
kubbVersion: options.kubbVersion,
|
|
154
|
+
nodeVersion: process$1.versions.node.split(".")[0],
|
|
155
|
+
runtime: runtime.name,
|
|
156
|
+
runtimeVersion: runtime.version.split(".")[0],
|
|
157
|
+
platform: os.platform(),
|
|
158
|
+
ci: isCIEnvironment(),
|
|
159
|
+
plugins: options.plugins ?? [],
|
|
160
|
+
duration,
|
|
161
|
+
filesCreated: options.filesCreated ?? 0,
|
|
162
|
+
status: options.status
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.
|
|
167
|
+
*
|
|
168
|
+
* @see https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/
|
|
169
|
+
*/
|
|
170
|
+
function buildOtlpPayload(event) {
|
|
171
|
+
const traceId = randomBytes(16).toString("hex");
|
|
172
|
+
const spanId = randomBytes(8).toString("hex");
|
|
173
|
+
const endTimeNs = BigInt(Date.now()) * 1000000n;
|
|
174
|
+
const startTimeNs = endTimeNs - BigInt(event.duration) * 1000000n;
|
|
175
|
+
const attributes = [
|
|
176
|
+
{
|
|
177
|
+
key: "kubb.command",
|
|
178
|
+
value: { stringValue: event.command }
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
key: "kubb.version",
|
|
182
|
+
value: { stringValue: event.kubbVersion }
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
key: "kubb.node_version",
|
|
186
|
+
value: { stringValue: event.nodeVersion }
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
key: "kubb.runtime",
|
|
190
|
+
value: { stringValue: event.runtime }
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
key: "kubb.runtime_version",
|
|
194
|
+
value: { stringValue: event.runtimeVersion }
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
key: "kubb.platform",
|
|
198
|
+
value: { stringValue: event.platform }
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
key: "kubb.ci",
|
|
202
|
+
value: { boolValue: event.ci }
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
key: "kubb.files_created",
|
|
206
|
+
value: { intValue: event.filesCreated }
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
key: "kubb.status",
|
|
210
|
+
value: { stringValue: event.status }
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
key: "kubb.plugins",
|
|
214
|
+
value: { arrayValue: { values: event.plugins.map((p) => ({ kvlistValue: { values: [{
|
|
215
|
+
key: "name",
|
|
216
|
+
value: { stringValue: p.name }
|
|
217
|
+
}, {
|
|
218
|
+
key: "options",
|
|
219
|
+
value: { stringValue: JSON.stringify({
|
|
220
|
+
...p.options,
|
|
221
|
+
usedEnumNames: void 0
|
|
222
|
+
}) }
|
|
223
|
+
}] } })) } }
|
|
224
|
+
}
|
|
225
|
+
];
|
|
226
|
+
return { resourceSpans: [{
|
|
227
|
+
resource: { attributes: [
|
|
228
|
+
{
|
|
229
|
+
key: "service.name",
|
|
230
|
+
value: { stringValue: "kubb-core" }
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
key: "service.version",
|
|
234
|
+
value: { stringValue: event.kubbVersion }
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
key: "telemetry.sdk.language",
|
|
238
|
+
value: { stringValue: "nodejs" }
|
|
239
|
+
}
|
|
240
|
+
] },
|
|
241
|
+
scopeSpans: [{
|
|
242
|
+
scope: {
|
|
243
|
+
name: "kubb-core",
|
|
244
|
+
version: event.kubbVersion
|
|
245
|
+
},
|
|
246
|
+
spans: [{
|
|
247
|
+
traceId,
|
|
248
|
+
spanId,
|
|
249
|
+
name: event.command,
|
|
250
|
+
kind: 1,
|
|
251
|
+
startTimeUnixNano: String(startTimeNs),
|
|
252
|
+
endTimeUnixNano: String(endTimeNs),
|
|
253
|
+
attributes,
|
|
254
|
+
status: { code: event.status === "success" ? 1 : 2 }
|
|
255
|
+
}]
|
|
256
|
+
}]
|
|
257
|
+
}] };
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and
|
|
261
|
+
* `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run. No file
|
|
262
|
+
* paths, OpenAPI specs, or secrets are sent.
|
|
263
|
+
*/
|
|
264
|
+
async function sendTelemetry(event) {
|
|
265
|
+
if (isDisabled()) return;
|
|
266
|
+
try {
|
|
267
|
+
await fetch(`${OTLP_ENDPOINT}/v1/traces`, {
|
|
268
|
+
method: "POST",
|
|
269
|
+
headers: {
|
|
270
|
+
"Content-Type": "application/json",
|
|
271
|
+
"Kubb-Telemetry-Version": "1",
|
|
272
|
+
"Kubb-Telemetry-Source": "kubb-core"
|
|
273
|
+
},
|
|
274
|
+
body: JSON.stringify(buildOtlpPayload(event)),
|
|
275
|
+
signal: AbortSignal.timeout(5e3)
|
|
276
|
+
});
|
|
277
|
+
} catch (_e) {}
|
|
278
|
+
}
|
|
279
|
+
//#endregion
|
|
280
|
+
export { QUIET_FLAGS as a, canUseTTY as c, KUBB_NPM_PACKAGE_URL as i, isDisabled as n, UPDATE_CHECK_TIMEOUT_MS as o, sendTelemetry as r, WATCHER_IGNORED_PATHS as s, buildTelemetryEvent as t };
|
|
281
|
+
|
|
282
|
+
//# sourceMappingURL=Telemetry-7z2tIqPm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Telemetry-7z2tIqPm.js","names":["process"],"sources":["../../../internals/utils/src/env.ts","../../../internals/utils/src/runtime.ts","../src/constants.ts","../src/Telemetry.ts"],"sourcesContent":["/**\n * Returns `true` when the process is running in a CI environment.\n * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,\n * TeamCity, Buildkite, and Azure Pipelines.\n *\n * @example\n * ```ts\n * if (isCIEnvironment()) {\n * logger.level = 'error'\n * }\n * ```\n */\nexport function isCIEnvironment(): boolean {\n return !!(\n process.env.CI ||\n process.env.GITHUB_ACTIONS ||\n process.env.GITLAB_CI ||\n process.env.BITBUCKET_BUILD_NUMBER ||\n process.env.JENKINS_URL ||\n process.env.CIRCLECI ||\n process.env.TRAVIS ||\n process.env.TEAMCITY_VERSION ||\n process.env.BUILDKITE ||\n process.env.TF_BUILD\n )\n}\n\n/**\n * Returns `true` when the process has an interactive TTY with a valid terminal\n * width and is not running in CI.\n *\n * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,\n * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`\n * with a negative count and throw a `RangeError`). We therefore require a\n * positive column count before declaring the TTY usable.\n *\n * @example\n * ```ts\n * if (canUseTTY()) {\n * renderProgressBar()\n * }\n * ```\n */\nexport function canUseTTY(): boolean {\n return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment()\n}\n","/**\n * Name of the JavaScript runtime executing the current process.\n */\ntype RuntimeName = 'bun' | 'deno' | 'node'\n\n/**\n * Detects the JavaScript runtime executing the current process and exposes its name and version.\n *\n * Prefer the shared {@link runtime} instance over constructing your own.\n */\nclass Runtime {\n /**\n * `true` when the current process is running under Bun.\n *\n * Detection keys off the global `Bun` object rather than `process.versions`,\n * because Bun polyfills `process.versions.node` for Node compatibility and would\n * otherwise look like Node.\n *\n * @example\n * ```ts\n * if (runtime.isBun) {\n * await Bun.write(path, data)\n * }\n * ```\n */\n get isBun(): boolean {\n return typeof Bun !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Deno.\n */\n get isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Node.\n *\n * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.\n */\n get isNode(): boolean {\n return !this.isBun && !this.isDeno && typeof process !== 'undefined' && process.versions?.node != null\n }\n\n /**\n * Name of the runtime executing the current process.\n *\n * @example\n * ```ts\n * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise\n * ```\n */\n get name(): RuntimeName {\n if (this.isBun) return 'bun'\n if (this.isDeno) return 'deno'\n\n return 'node'\n }\n\n /**\n * Version of the active runtime, or an empty string when it cannot be read.\n *\n * @example\n * ```ts\n * runtime.version // '1.3.11' under Bun, '22.22.2' under Node\n * ```\n */\n get version(): string {\n if (this.isBun) return process.versions.bun ?? ''\n if (this.isDeno) return (globalThis as { Deno?: { version?: { deno?: string } } }).Deno?.version?.deno ?? ''\n\n return process.versions?.node ?? ''\n }\n}\n\n/**\n * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.\n */\nexport const runtime = new Runtime()\n","/**\n * NPM registry endpoint used to check for @kubb/cli updates.\n */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/**\n * OpenTelemetry ingestion endpoint for anonymous usage telemetry.\n */\nexport const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\n/**\n * Glob pattern for paths the file watcher ignores.\n */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Quiet window in milliseconds that collapses a burst of watcher events (an editor save emits\n * several) into a single rebuild.\n */\nexport const WATCHER_DEBOUNCE_MS = 100\n\n/**\n * Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run.\n */\nexport const UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/**\n * Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.\n */\nexport const QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v'])\n","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { isCIEnvironment, runtime } from '@internals/utils'\nimport { OTLP_ENDPOINT } from './constants.ts'\n\ntype OtlpKeyValue = {\n key: string\n value:\n | { stringValue: string }\n | { boolValue: boolean }\n | { intValue: number }\n | { arrayValue: { values: Array<{ kvlistValue: { values: Array<OtlpKeyValue> } }> } }\n | { kvlistValue: { values: Array<OtlpKeyValue> } }\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n name: string\n kind: 1\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes: Array<OtlpKeyValue>\n status: { code: 1 | 2 }\n}\n\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: Array<{\n resource: { attributes: Array<OtlpKeyValue> }\n scopeSpans: Array<{\n scope: { name: string; version: string }\n spans: Array<OtlpSpan>\n }>\n }>\n}\n\n/**\n * Anonymous plugin name and options snapshot sent with each telemetry event.\n */\nexport type TelemetryPlugin = {\n /**\n * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.\n */\n name: string\n /**\n * Anonymized snapshot of the plugin options. Values are included but cannot be traced back to a user.\n */\n options: Record<string, unknown>\n}\n\n/**\n * Anonymous snapshot of a single Kubb run, built by {@link buildTelemetryEvent} and sent by {@link sendTelemetry}.\n */\nexport type TelemetryEvent = {\n command: string\n kubbVersion: string\n /**\n * Major version of Node that executed the run, e.g. `'22'`.\n */\n nodeVersion: string\n /**\n * Name of the JavaScript runtime that executed the run, `'bun'`, `'deno'`, or `'node'`.\n */\n runtime: string\n /**\n * Major version of the active runtime, e.g. `'1'` under Bun or `'22'` under Node.\n */\n runtimeVersion: string\n platform: string\n ci: boolean\n plugins: Array<TelemetryPlugin>\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\nexport function isDisabled(): boolean {\n return (\n process.env['DO_NOT_TRACK'] === '1' ||\n process.env['DO_NOT_TRACK'] === 'true' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === '1' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === 'true'\n )\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n */\nexport function buildTelemetryEvent(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\n kubbVersion: string\n plugins?: Array<TelemetryPlugin>\n hrStart: [number, number]\n filesCreated?: number\n status: 'success' | 'failed'\n}): TelemetryEvent {\n const [seconds, nanoseconds] = process.hrtime(options.hrStart)\n const duration = Math.round(seconds * 1000 + nanoseconds / 1e6)\n\n return {\n command: options.command,\n kubbVersion: options.kubbVersion,\n nodeVersion: process.versions.node.split('.')[0] as string,\n runtime: runtime.name,\n runtimeVersion: runtime.version.split('.')[0] as string,\n platform: os.platform(),\n ci: isCIEnvironment(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n\n/**\n * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.\n *\n * @see https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/\n */\nexport function buildOtlpPayload(event: TelemetryEvent): OtlpExportTraceServiceRequest {\n const traceId = randomBytes(16).toString('hex')\n const spanId = randomBytes(8).toString('hex')\n const endTimeNs = BigInt(Date.now()) * 1_000_000n\n const startTimeNs = endTimeNs - BigInt(event.duration) * 1_000_000n\n\n const attributes: Array<OtlpKeyValue> = [\n { key: 'kubb.command', value: { stringValue: event.command } },\n { key: 'kubb.version', value: { stringValue: event.kubbVersion } },\n { key: 'kubb.node_version', value: { stringValue: event.nodeVersion } },\n { key: 'kubb.runtime', value: { stringValue: event.runtime } },\n { key: 'kubb.runtime_version', value: { stringValue: event.runtimeVersion } },\n { key: 'kubb.platform', value: { stringValue: event.platform } },\n { key: 'kubb.ci', value: { boolValue: event.ci } },\n { key: 'kubb.files_created', value: { intValue: event.filesCreated } },\n { key: 'kubb.status', value: { stringValue: event.status } },\n {\n key: 'kubb.plugins',\n value: {\n arrayValue: {\n values: event.plugins.map((p) => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n {\n key: 'options',\n value: {\n stringValue: JSON.stringify({\n ...p.options,\n usedEnumNames: undefined,\n }),\n },\n },\n ],\n },\n })),\n },\n },\n },\n ]\n\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n { key: 'service.name', value: { stringValue: 'kubb-core' } },\n {\n key: 'service.version',\n value: { stringValue: event.kubbVersion },\n },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-core', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: {\n code: event.status === 'success' ? 1 : 2,\n },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and\n * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run. No file\n * paths, OpenAPI specs, or secrets are sent.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isDisabled()) {\n return\n }\n\n try {\n await fetch(`${OTLP_ENDPOINT}/v1/traces`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Kubb-Telemetry-Version': '1',\n 'Kubb-Telemetry-Source': 'kubb-core',\n },\n body: JSON.stringify(buildOtlpPayload(event)),\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