@kubb/cli 4.31.6 → 4.32.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.
Files changed (47) hide show
  1. package/dist/{agent-B1CUGkYz.js → agent-8jG3rl0B.js} +4 -5
  2. package/dist/{agent-B1CUGkYz.js.map → agent-8jG3rl0B.js.map} +1 -1
  3. package/dist/{agent-Br81MODN.cjs → agent-BsD5PHB2.cjs} +4 -5
  4. package/dist/{agent-Br81MODN.cjs.map → agent-BsD5PHB2.cjs.map} +1 -1
  5. package/dist/{chunk-DKWOrOAv.js → chunk--u3MIqq1.js} +1 -2
  6. package/dist/{chunk-CNbaEX1y.cjs → chunk-ByKO4r7w.cjs} +17 -23
  7. package/dist/{generate-CFkQETAA.cjs → generate-ClQhVqk5.cjs} +5 -21
  8. package/dist/{generate-CFkQETAA.cjs.map → generate-ClQhVqk5.cjs.map} +1 -1
  9. package/dist/{generate--tYZWfqN.js → generate-CrZtyHgq.js} +5 -21
  10. package/dist/{generate--tYZWfqN.js.map → generate-CrZtyHgq.js.map} +1 -1
  11. package/dist/index.cjs +11 -12
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +10 -11
  15. package/dist/index.js.map +1 -1
  16. package/dist/{init-s3odyJiy.js → init-38_4Jmfa.js} +4 -6
  17. package/dist/{init-s3odyJiy.js.map → init-38_4Jmfa.js.map} +1 -1
  18. package/dist/{init-BowCpIjT.cjs → init-CB9TSmNM.cjs} +4 -6
  19. package/dist/{init-BowCpIjT.cjs.map → init-CB9TSmNM.cjs.map} +1 -1
  20. package/dist/{mcp-DXZFrWqT.js → mcp-9F5pyhZ2.js} +5 -6
  21. package/dist/{mcp-DXZFrWqT.js.map → mcp-9F5pyhZ2.js.map} +1 -1
  22. package/dist/{mcp-Do1d--r_.cjs → mcp-C0Xl0YGt.cjs} +6 -8
  23. package/dist/{mcp-Do1d--r_.cjs.map → mcp-C0Xl0YGt.cjs.map} +1 -1
  24. package/dist/package-CKryUEad.cjs +11 -0
  25. package/dist/package-CKryUEad.cjs.map +1 -0
  26. package/dist/package-Drh57N7E.js +6 -0
  27. package/dist/package-Drh57N7E.js.map +1 -0
  28. package/dist/{start-DFNsdJzA.cjs → start-A46Rk5Kk.cjs} +6 -12
  29. package/dist/start-A46Rk5Kk.cjs.map +1 -0
  30. package/dist/{start-DiHg3Vn9.js → start-DsVrgGmj.js} +6 -12
  31. package/dist/start-DsVrgGmj.js.map +1 -0
  32. package/dist/{telemetry-BcdCgNDv.cjs → telemetry-BDSSqUiG.cjs} +18 -19
  33. package/dist/{telemetry-BcdCgNDv.cjs.map → telemetry-BDSSqUiG.cjs.map} +1 -1
  34. package/dist/{telemetry-4xNBLqQy.js → telemetry-DYWvlxqs.js} +3 -4
  35. package/dist/{telemetry-4xNBLqQy.js.map → telemetry-DYWvlxqs.js.map} +1 -1
  36. package/dist/{validate-BAoV_Yr0.cjs → validate-Cl24nvUu.cjs} +6 -8
  37. package/dist/{validate-BAoV_Yr0.cjs.map → validate-Cl24nvUu.cjs.map} +1 -1
  38. package/dist/{validate-CujTQNa8.js → validate-DN-TyVLr.js} +5 -6
  39. package/dist/{validate-CujTQNa8.js.map → validate-DN-TyVLr.js.map} +1 -1
  40. package/package.json +5 -5
  41. package/src/commands/agent/start.ts +2 -9
  42. package/dist/package-BuRPi56s.cjs +0 -12
  43. package/dist/package-BuRPi56s.cjs.map +0 -1
  44. package/dist/package-CxCdHR6N.js +0 -6
  45. package/dist/package-CxCdHR6N.js.map +0 -1
  46. package/dist/start-DFNsdJzA.cjs.map +0 -1
  47. package/dist/start-DiHg3Vn9.js.map +0 -1
@@ -1,11 +1,10 @@
1
- const require_chunk = require('./chunk-CNbaEX1y.cjs');
1
+ const require_chunk = require("./chunk-ByKO4r7w.cjs");
2
2
  let node_crypto = require("node:crypto");
3
3
  let node_os = require("node:os");
4
4
  node_os = require_chunk.__toESM(node_os);
5
5
  let node_process = require("node:process");
6
6
  node_process = require_chunk.__toESM(node_process);
7
7
  let _kubb_core_utils = require("@kubb/core/utils");
8
-
9
8
  //#region src/utils/telemetry.ts
10
9
  const OTLP_ENDPOINT = "https://otlp.kubb.dev";
11
10
  /**
@@ -148,24 +147,24 @@ function buildTelemetryEvent(options) {
148
147
  status: options.status
149
148
  };
150
149
  }
151
-
152
150
  //#endregion
153
- Object.defineProperty(exports, 'buildTelemetryEvent', {
154
- enumerable: true,
155
- get: function () {
156
- return buildTelemetryEvent;
157
- }
151
+ Object.defineProperty(exports, "buildTelemetryEvent", {
152
+ enumerable: true,
153
+ get: function() {
154
+ return buildTelemetryEvent;
155
+ }
158
156
  });
159
- Object.defineProperty(exports, 'isTelemetryDisabled', {
160
- enumerable: true,
161
- get: function () {
162
- return isTelemetryDisabled;
163
- }
157
+ Object.defineProperty(exports, "isTelemetryDisabled", {
158
+ enumerable: true,
159
+ get: function() {
160
+ return isTelemetryDisabled;
161
+ }
164
162
  });
165
- Object.defineProperty(exports, 'sendTelemetry', {
166
- enumerable: true,
167
- get: function () {
168
- return sendTelemetry;
169
- }
163
+ Object.defineProperty(exports, "sendTelemetry", {
164
+ enumerable: true,
165
+ get: function() {
166
+ return sendTelemetry;
167
+ }
170
168
  });
171
- //# sourceMappingURL=telemetry-BcdCgNDv.cjs.map
169
+
170
+ //# sourceMappingURL=telemetry-BDSSqUiG.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-BcdCgNDv.cjs","names":["process","os"],"sources":["../src/utils/telemetry.ts"],"sourcesContent":["import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { executeIfOnline } from '@kubb/core/utils'\n\nconst OTLP_ENDPOINT = 'https://otlp.kubb.dev'\n\n// ---------------------------------------------------------------------------\n// OpenTelemetry OTLP JSON types\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/common/v1/common.proto\n// ---------------------------------------------------------------------------\n\ntype OtlpStringValue = { stringValue: string }\ntype OtlpBoolValue = { boolValue: boolean }\ntype OtlpIntValue = { intValue: number }\ntype OtlpDoubleValue = { doubleValue: number }\ntype OtlpBytesValue = { bytesValue: string }\ntype OtlpArrayValue = { arrayValue: { values: OtlpAnyValue[] } }\ntype OtlpKvListValue = { kvlistValue: { values: OtlpKeyValue[] } }\n\ntype OtlpAnyValue = OtlpStringValue | OtlpBoolValue | OtlpIntValue | OtlpDoubleValue | OtlpBytesValue | OtlpArrayValue | OtlpKvListValue\n\ntype OtlpKeyValue = {\n key: string\n value: OtlpAnyValue\n}\n\ntype OtlpResource = {\n attributes: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpInstrumentationScope = {\n name: string\n version?: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\n/** https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L103 */\ntype OtlpSpanKind = 0 | 1 | 2 | 3 | 4 | 5\n\n/** 0 = STATUS_CODE_UNSET, 1 = STATUS_CODE_OK, 2 = STATUS_CODE_ERROR */\ntype OtlpStatusCode = 0 | 1 | 2\n\ntype OtlpStatus = {\n code: OtlpStatusCode\n message?: string\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n traceState?: string\n parentSpanId?: string\n name: string\n kind: OtlpSpanKind\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n events?: OtlpSpanEvent[]\n droppedEventsCount?: number\n links?: OtlpSpanLink[]\n droppedLinksCount?: number\n status?: OtlpStatus\n}\n\ntype OtlpSpanEvent = {\n timeUnixNano: string\n name: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpSpanLink = {\n traceId: string\n spanId: string\n traceState?: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpScopeSpans = {\n scope: OtlpInstrumentationScope\n spans: OtlpSpan[]\n schemaUrl?: string\n}\n\ntype OtlpResourceSpans = {\n resource: OtlpResource\n scopeSpans: OtlpScopeSpans[]\n schemaUrl?: string\n}\n\n/** Root payload sent to POST /v1/traces */\nexport type OtlpExportTraceServiceRequest = {\n resourceSpans: OtlpResourceSpans[]\n}\n\n// ---------------------------------------------------------------------------\n\nexport type TelemetryPlugin = {\n name: string\n options: Record<string, unknown>\n}\n\nexport type TelemetryEvent = {\n command: string\n kubbVersion: string\n nodeVersion: string\n platform: string\n ci: boolean\n plugins: TelemetryPlugin[]\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Detect whether the current process is running inside a CI environment by\n * checking the well-known environment variables set by all major CI systems.\n */\nexport function isCi(): boolean {\n return !!(\n (\n process.env['CI'] || // Generic (GitHub Actions, GitLab CI, CircleCI, Travis CI, etc.)\n process.env['GITHUB_ACTIONS'] || // GitHub Actions\n process.env['GITLAB_CI'] || // GitLab CI\n process.env['BITBUCKET_BUILD_NUMBER'] || // Bitbucket Pipelines\n process.env['JENKINS_URL'] || // Jenkins\n process.env['CIRCLECI'] || // CircleCI\n process.env['TRAVIS'] || // Travis CI\n process.env['TEAMCITY_VERSION'] || // TeamCity\n process.env['BUILDKITE'] || // Buildkite\n process.env['TF_BUILD']\n ) // Azure Pipelines\n )\n}\n\n/**\n * Check if telemetry is disabled via DO_NOT_TRACK or KUBB_DISABLE_TELEMETRY.\n * Respects the standard DO_NOT_TRACK convention used across development tools.\n */\nexport function isTelemetryDisabled(): 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 * Convert a TelemetryEvent into an OTLP-compatible JSON trace payload.\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: 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.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(\n (p): OtlpKvListValue => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n { key: 'options', value: { stringValue: JSON.stringify({ ...p.options, usedEnumNames: undefined }) } },\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-cli' } },\n { key: 'service.version', value: { stringValue: event.kubbVersion } },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-cli', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1 satisfies OtlpSpanKind,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: { code: (event.status === 'success' ? 1 : 2) satisfies OtlpStatusCode },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint.\n * Respects DO_NOT_TRACK and KUBB_DISABLE_TELEMETRY environment variables.\n * Fails silently to never interrupt the generation process.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isTelemetryDisabled()) {\n return\n }\n\n await executeIfOnline(async () => {\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-cli',\n },\n body: JSON.stringify(buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently – telemetry must never break the CLI\n }\n })\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n * No file paths, OpenAPI specs, or secrets are included.\n */\nexport function buildTelemetryEvent(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\n kubbVersion: string\n plugins?: 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] ?? 'unknown',\n platform: os.platform(),\n ci: isCi(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n"],"mappings":";;;;;;;;;AAKA,MAAM,gBAAgB;;;;;AAuHtB,SAAgB,OAAgB;AAC9B,QAAO,CAAC,EAEJA,qBAAQ,IAAI,SACZA,qBAAQ,IAAI,qBACZA,qBAAQ,IAAI,gBACZA,qBAAQ,IAAI,6BACZA,qBAAQ,IAAI,kBACZA,qBAAQ,IAAI,eACZA,qBAAQ,IAAI,aACZA,qBAAQ,IAAI,uBACZA,qBAAQ,IAAI,gBACZA,qBAAQ,IAAI;;;;;;AASlB,SAAgB,sBAA+B;AAC7C,QACEA,qBAAQ,IAAI,oBAAoB,OAChCA,qBAAQ,IAAI,oBAAoB,UAChCA,qBAAQ,IAAI,8BAA8B,OAC1CA,qBAAQ,IAAI,8BAA8B;;;;;;AAQ9C,SAAgB,iBAAiB,OAAsD;CACrF,MAAM,uC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D,OAAO,CACL;IACE;IACA;IACA,MAAM,MAAM;IACZ,MAAM;IACN,mBAAmB,OAAO,YAAY;IACtC,iBAAiB,OAAO,UAAU;IAClC;IACA,QAAQ,EAAE,MAAO,MAAM,WAAW,YAAY,IAAI,GAA6B;IAChF,CACF;GACF,CACF;EACF,CACF,EACF;;;;;;;AAQH,eAAsB,cAAc,OAAsC;AACxE,KAAI,qBAAqB,CACvB;AAGF,6CAAsB,YAAY;AAChC,MAAI;AACF,SAAM,MAAM,GAAG,cAAc,aAAa;IACxC,QAAQ;IACR,SAAS;KACP,gBAAgB;KAChB,0BAA0B;KAC1B,yBAAyB;KAC1B;IACD,MAAM,KAAK,UAAU,iBAAiB,MAAM,CAAC;IAC7C,QAAQ,YAAY,QAAQ,IAAM;IACnC,CAAC;WACK,IAAI;GAGb;;;;;;AAOJ,SAAgB,oBAAoB,SAOjB;CACjB,MAAM,CAAC,SAAS,eAAeA,qBAAQ,OAAO,QAAQ,QAAQ;CAC9D,MAAM,WAAW,KAAK,MAAM,UAAU,MAAO,cAAc,IAAI;AAE/D,QAAO;EACL,SAAS,QAAQ;EACjB,aAAa,QAAQ;EACrB,aAAaA,qBAAQ,SAAS,KAAK,MAAM,IAAI,CAAC,MAAM;EACpD,UAAUC,gBAAG,UAAU;EACvB,IAAI,MAAM;EACV,SAAS,QAAQ,WAAW,EAAE;EAC9B;EACA,cAAc,QAAQ,gBAAgB;EACtC,QAAQ,QAAQ;EACjB"}
1
+ {"version":3,"file":"telemetry-BDSSqUiG.cjs","names":["process","os"],"sources":["../src/utils/telemetry.ts"],"sourcesContent":["import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { executeIfOnline } from '@kubb/core/utils'\n\nconst OTLP_ENDPOINT = 'https://otlp.kubb.dev'\n\n// ---------------------------------------------------------------------------\n// OpenTelemetry OTLP JSON types\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/common/v1/common.proto\n// ---------------------------------------------------------------------------\n\ntype OtlpStringValue = { stringValue: string }\ntype OtlpBoolValue = { boolValue: boolean }\ntype OtlpIntValue = { intValue: number }\ntype OtlpDoubleValue = { doubleValue: number }\ntype OtlpBytesValue = { bytesValue: string }\ntype OtlpArrayValue = { arrayValue: { values: OtlpAnyValue[] } }\ntype OtlpKvListValue = { kvlistValue: { values: OtlpKeyValue[] } }\n\ntype OtlpAnyValue = OtlpStringValue | OtlpBoolValue | OtlpIntValue | OtlpDoubleValue | OtlpBytesValue | OtlpArrayValue | OtlpKvListValue\n\ntype OtlpKeyValue = {\n key: string\n value: OtlpAnyValue\n}\n\ntype OtlpResource = {\n attributes: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpInstrumentationScope = {\n name: string\n version?: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\n/** https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L103 */\ntype OtlpSpanKind = 0 | 1 | 2 | 3 | 4 | 5\n\n/** 0 = STATUS_CODE_UNSET, 1 = STATUS_CODE_OK, 2 = STATUS_CODE_ERROR */\ntype OtlpStatusCode = 0 | 1 | 2\n\ntype OtlpStatus = {\n code: OtlpStatusCode\n message?: string\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n traceState?: string\n parentSpanId?: string\n name: string\n kind: OtlpSpanKind\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n events?: OtlpSpanEvent[]\n droppedEventsCount?: number\n links?: OtlpSpanLink[]\n droppedLinksCount?: number\n status?: OtlpStatus\n}\n\ntype OtlpSpanEvent = {\n timeUnixNano: string\n name: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpSpanLink = {\n traceId: string\n spanId: string\n traceState?: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpScopeSpans = {\n scope: OtlpInstrumentationScope\n spans: OtlpSpan[]\n schemaUrl?: string\n}\n\ntype OtlpResourceSpans = {\n resource: OtlpResource\n scopeSpans: OtlpScopeSpans[]\n schemaUrl?: string\n}\n\n/** Root payload sent to POST /v1/traces */\nexport type OtlpExportTraceServiceRequest = {\n resourceSpans: OtlpResourceSpans[]\n}\n\n// ---------------------------------------------------------------------------\n\nexport type TelemetryPlugin = {\n name: string\n options: Record<string, unknown>\n}\n\nexport type TelemetryEvent = {\n command: string\n kubbVersion: string\n nodeVersion: string\n platform: string\n ci: boolean\n plugins: TelemetryPlugin[]\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Detect whether the current process is running inside a CI environment by\n * checking the well-known environment variables set by all major CI systems.\n */\nexport function isCi(): boolean {\n return !!(\n (\n process.env['CI'] || // Generic (GitHub Actions, GitLab CI, CircleCI, Travis CI, etc.)\n process.env['GITHUB_ACTIONS'] || // GitHub Actions\n process.env['GITLAB_CI'] || // GitLab CI\n process.env['BITBUCKET_BUILD_NUMBER'] || // Bitbucket Pipelines\n process.env['JENKINS_URL'] || // Jenkins\n process.env['CIRCLECI'] || // CircleCI\n process.env['TRAVIS'] || // Travis CI\n process.env['TEAMCITY_VERSION'] || // TeamCity\n process.env['BUILDKITE'] || // Buildkite\n process.env['TF_BUILD']\n ) // Azure Pipelines\n )\n}\n\n/**\n * Check if telemetry is disabled via DO_NOT_TRACK or KUBB_DISABLE_TELEMETRY.\n * Respects the standard DO_NOT_TRACK convention used across development tools.\n */\nexport function isTelemetryDisabled(): 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 * Convert a TelemetryEvent into an OTLP-compatible JSON trace payload.\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: 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.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(\n (p): OtlpKvListValue => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n { key: 'options', value: { stringValue: JSON.stringify({ ...p.options, usedEnumNames: undefined }) } },\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-cli' } },\n { key: 'service.version', value: { stringValue: event.kubbVersion } },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-cli', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1 satisfies OtlpSpanKind,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: { code: (event.status === 'success' ? 1 : 2) satisfies OtlpStatusCode },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint.\n * Respects DO_NOT_TRACK and KUBB_DISABLE_TELEMETRY environment variables.\n * Fails silently to never interrupt the generation process.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isTelemetryDisabled()) {\n return\n }\n\n await executeIfOnline(async () => {\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-cli',\n },\n body: JSON.stringify(buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently – telemetry must never break the CLI\n }\n })\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n * No file paths, OpenAPI specs, or secrets are included.\n */\nexport function buildTelemetryEvent(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\n kubbVersion: string\n plugins?: 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] ?? 'unknown',\n platform: os.platform(),\n ci: isCi(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n"],"mappings":";;;;;;;;AAKA,MAAM,gBAAgB;;;;;AAuHtB,SAAgB,OAAgB;AAC9B,QAAO,CAAC,EAEJA,aAAAA,QAAQ,IAAI,SACZA,aAAAA,QAAQ,IAAI,qBACZA,aAAAA,QAAQ,IAAI,gBACZA,aAAAA,QAAQ,IAAI,6BACZA,aAAAA,QAAQ,IAAI,kBACZA,aAAAA,QAAQ,IAAI,eACZA,aAAAA,QAAQ,IAAI,aACZA,aAAAA,QAAQ,IAAI,uBACZA,aAAAA,QAAQ,IAAI,gBACZA,aAAAA,QAAQ,IAAI;;;;;;AASlB,SAAgB,sBAA+B;AAC7C,QACEA,aAAAA,QAAQ,IAAI,oBAAoB,OAChCA,aAAAA,QAAQ,IAAI,oBAAoB,UA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EAAE,aAAa,MAAM,aAAa;IAAE;GACrE;IAAE,KAAK;IAA0B,OAAO,EAAE,aAAa,UAAU;IAAE;GACpE,EACF;EACD,YAAY,CACV;GACE,OAAO;IAAE,MAAM;IAAY,SAAS,MAAM;IAAa;GACvD,OAAO,CACL;IACE;IACA;IACA,MAAM,MAAM;IACZ,MAAM;IACN,mBAAmB,OAAO,YAAY;IACtC,iBAAiB,OAAO,UAAU;IAClC;IACA,QAAQ,EAAE,MAAO,MAAM,WAAW,YAAY,IAAI,GAA6B;IAChF,CACF;GACF,CACF;EACF,CACF,EACF;;;;;;;AAQH,eAAsB,cAAc,OAAsC;AACxE,KAAI,qBAAqB,CACvB;AAGF,QAAA,GAAA,iBAAA,iBAAsB,YAAY;AAChC,MAAI;AACF,SAAM,MAAM,GAAG,cAAc,aAAa;IACxC,QAAQ;IACR,SAAS;KACP,gBAAgB;KAChB,0BAA0B;KAC1B,yBAAyB;KAC1B;IACD,MAAM,KAAK,UAAU,iBAAiB,MAAM,CAAC;IAC7C,QAAQ,YAAY,QAAQ,IAAM;IACnC,CAAC;WACK,IAAI;GAGb;;;;;;AAOJ,SAAgB,oBAAoB,SAOjB;CACjB,MAAM,CAAC,SAAS,eAAeA,aAAAA,QAAQ,OAAO,QAAQ,QAAQ;CAC9D,MAAM,WAAW,KAAK,MAAM,UAAU,MAAO,cAAc,IAAI;AAE/D,QAAO;EACL,SAAS,QAAQ;EACjB,aAAa,QAAQ;EACrB,aAAaA,aAAAA,QAAQ,SAAS,KAAK,MAAM,IAAI,CAAC,MAAM;EACpD,UAAUC,QAAAA,QAAG,UAAU;EACvB,IAAI,MAAM;EACV,SAAS,QAAQ,WAAW,EAAE;EAC9B;EACA,cAAc,QAAQ,gBAAgB;EACtC,QAAQ,QAAQ;EACjB"}
@@ -1,9 +1,8 @@
1
- import { t as __name } from "./chunk-DKWOrOAv.js";
1
+ import "./chunk--u3MIqq1.js";
2
2
  import { randomBytes } from "node:crypto";
3
3
  import os from "node:os";
4
4
  import process from "node:process";
5
5
  import { executeIfOnline } from "@kubb/core/utils";
6
-
7
6
  //#region src/utils/telemetry.ts
8
7
  const OTLP_ENDPOINT = "https://otlp.kubb.dev";
9
8
  /**
@@ -146,7 +145,7 @@ function buildTelemetryEvent(options) {
146
145
  status: options.status
147
146
  };
148
147
  }
149
-
150
148
  //#endregion
151
149
  export { isTelemetryDisabled as n, sendTelemetry as r, buildTelemetryEvent as t };
152
- //# sourceMappingURL=telemetry-4xNBLqQy.js.map
150
+
151
+ //# sourceMappingURL=telemetry-DYWvlxqs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-4xNBLqQy.js","names":[],"sources":["../src/utils/telemetry.ts"],"sourcesContent":["import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { executeIfOnline } from '@kubb/core/utils'\n\nconst OTLP_ENDPOINT = 'https://otlp.kubb.dev'\n\n// ---------------------------------------------------------------------------\n// OpenTelemetry OTLP JSON types\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/common/v1/common.proto\n// ---------------------------------------------------------------------------\n\ntype OtlpStringValue = { stringValue: string }\ntype OtlpBoolValue = { boolValue: boolean }\ntype OtlpIntValue = { intValue: number }\ntype OtlpDoubleValue = { doubleValue: number }\ntype OtlpBytesValue = { bytesValue: string }\ntype OtlpArrayValue = { arrayValue: { values: OtlpAnyValue[] } }\ntype OtlpKvListValue = { kvlistValue: { values: OtlpKeyValue[] } }\n\ntype OtlpAnyValue = OtlpStringValue | OtlpBoolValue | OtlpIntValue | OtlpDoubleValue | OtlpBytesValue | OtlpArrayValue | OtlpKvListValue\n\ntype OtlpKeyValue = {\n key: string\n value: OtlpAnyValue\n}\n\ntype OtlpResource = {\n attributes: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpInstrumentationScope = {\n name: string\n version?: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\n/** https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L103 */\ntype OtlpSpanKind = 0 | 1 | 2 | 3 | 4 | 5\n\n/** 0 = STATUS_CODE_UNSET, 1 = STATUS_CODE_OK, 2 = STATUS_CODE_ERROR */\ntype OtlpStatusCode = 0 | 1 | 2\n\ntype OtlpStatus = {\n code: OtlpStatusCode\n message?: string\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n traceState?: string\n parentSpanId?: string\n name: string\n kind: OtlpSpanKind\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n events?: OtlpSpanEvent[]\n droppedEventsCount?: number\n links?: OtlpSpanLink[]\n droppedLinksCount?: number\n status?: OtlpStatus\n}\n\ntype OtlpSpanEvent = {\n timeUnixNano: string\n name: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpSpanLink = {\n traceId: string\n spanId: string\n traceState?: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpScopeSpans = {\n scope: OtlpInstrumentationScope\n spans: OtlpSpan[]\n schemaUrl?: string\n}\n\ntype OtlpResourceSpans = {\n resource: OtlpResource\n scopeSpans: OtlpScopeSpans[]\n schemaUrl?: string\n}\n\n/** Root payload sent to POST /v1/traces */\nexport type OtlpExportTraceServiceRequest = {\n resourceSpans: OtlpResourceSpans[]\n}\n\n// ---------------------------------------------------------------------------\n\nexport type TelemetryPlugin = {\n name: string\n options: Record<string, unknown>\n}\n\nexport type TelemetryEvent = {\n command: string\n kubbVersion: string\n nodeVersion: string\n platform: string\n ci: boolean\n plugins: TelemetryPlugin[]\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Detect whether the current process is running inside a CI environment by\n * checking the well-known environment variables set by all major CI systems.\n */\nexport function isCi(): boolean {\n return !!(\n (\n process.env['CI'] || // Generic (GitHub Actions, GitLab CI, CircleCI, Travis CI, etc.)\n process.env['GITHUB_ACTIONS'] || // GitHub Actions\n process.env['GITLAB_CI'] || // GitLab CI\n process.env['BITBUCKET_BUILD_NUMBER'] || // Bitbucket Pipelines\n process.env['JENKINS_URL'] || // Jenkins\n process.env['CIRCLECI'] || // CircleCI\n process.env['TRAVIS'] || // Travis CI\n process.env['TEAMCITY_VERSION'] || // TeamCity\n process.env['BUILDKITE'] || // Buildkite\n process.env['TF_BUILD']\n ) // Azure Pipelines\n )\n}\n\n/**\n * Check if telemetry is disabled via DO_NOT_TRACK or KUBB_DISABLE_TELEMETRY.\n * Respects the standard DO_NOT_TRACK convention used across development tools.\n */\nexport function isTelemetryDisabled(): 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 * Convert a TelemetryEvent into an OTLP-compatible JSON trace payload.\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: 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.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(\n (p): OtlpKvListValue => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n { key: 'options', value: { stringValue: JSON.stringify({ ...p.options, usedEnumNames: undefined }) } },\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-cli' } },\n { key: 'service.version', value: { stringValue: event.kubbVersion } },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-cli', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1 satisfies OtlpSpanKind,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: { code: (event.status === 'success' ? 1 : 2) satisfies OtlpStatusCode },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint.\n * Respects DO_NOT_TRACK and KUBB_DISABLE_TELEMETRY environment variables.\n * Fails silently to never interrupt the generation process.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isTelemetryDisabled()) {\n return\n }\n\n await executeIfOnline(async () => {\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-cli',\n },\n body: JSON.stringify(buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently – telemetry must never break the CLI\n }\n })\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n * No file paths, OpenAPI specs, or secrets are included.\n */\nexport function buildTelemetryEvent(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\n kubbVersion: string\n plugins?: 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] ?? 'unknown',\n platform: os.platform(),\n ci: isCi(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n"],"mappings":";;;;;;;AAKA,MAAM,gBAAgB;;;;;AAuHtB,SAAgB,OAAgB;AAC9B,QAAO,CAAC,EAEJ,QAAQ,IAAI,SACZ,QAAQ,IAAI,qBACZ,QAAQ,IAAI,gBACZ,QAAQ,IAAI,6BACZ,QAAQ,IAAI,kBACZ,QAAQ,IAAI,eACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI,uBACZ,QAAQ,IAAI,gBACZ,QAAQ,IAAI;;;;;;AASlB,SAAgB,sBAA+B;AAC7C,QACE,QAAQ,IAAI,oBAAoB,OAChC,QAAQ,IAAI,oBAAoB,UAChC,QAAQ,IAAI,8BAA8B,OAC1C,QAAQ,IAAI,8BAA8B;;;;;;AAQ9C,SAAgB,iBAAiB,OAAsD;CACrF,MAAM,UAAU,YAAY,GAAG,CAAC,SAAS,MAAM;CAC/C,MAAM,SAAS,YAAY,EAAE,CAAC,SAAS,MAAM;CAC7C,MAAM,YAAY,OAAO,KAAK,KAAK,CAAC,GAAG;CACvC,MAAM,cAAc,YAAY,OAAO,MAAM,SAAS,GAAG;CAEzD,MAAM,aAA6B;EACjC;GAAE,KAAK;GAAgB,OAAO,EAAE,aAAa,MAAM,SAAS;GAAE;EAC9D;GAAE,KAAK;GAAgB,OAAO,EAAE,aAAa,MAAM,aAAa;GAAE;EAClE;GAAE,KAAK;GAAqB,OAAO,EAAE,aAAa,MAAM,aAAa;GAAE;EACvE;GAAE,KAAK;GAAiB,OAAO,EAAE,aAAa,MAAM,UAAU;GAAE;EAChE;GAAE,KAAK;GAAW,OAAO,EAAE,WAAW,MAAM,IAAI;GAAE;EAClD;GAAE,KAAK;GAAsB,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,SAAgB,oBAAoB,SAOjB;CACjB,MAAM,CAAC,SAAS,eAAe,QAAQ,OAAO,QAAQ,QAAQ;CAC9D,MAAM,WAAW,KAAK,MAAM,UAAU,MAAO,cAAc,IAAI;AAE/D,QAAO;EACL,SAAS,QAAQ;EACjB,aAAa,QAAQ;EACrB,aAAa,QAAQ,SAAS,KAAK,MAAM,IAAI,CAAC,MAAM;EACpD,UAAU,GAAG,UAAU;EACvB,IAAI,MAAM;EACV,SAAS,QAAQ,WAAW,EAAE;EAC9B;EACA,cAAc,QAAQ,gBAAgB;EACtC,QAAQ,QAAQ;EACjB"}
1
+ {"version":3,"file":"telemetry-DYWvlxqs.js","names":[],"sources":["../src/utils/telemetry.ts"],"sourcesContent":["import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { executeIfOnline } from '@kubb/core/utils'\n\nconst OTLP_ENDPOINT = 'https://otlp.kubb.dev'\n\n// ---------------------------------------------------------------------------\n// OpenTelemetry OTLP JSON types\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/common/v1/common.proto\n// ---------------------------------------------------------------------------\n\ntype OtlpStringValue = { stringValue: string }\ntype OtlpBoolValue = { boolValue: boolean }\ntype OtlpIntValue = { intValue: number }\ntype OtlpDoubleValue = { doubleValue: number }\ntype OtlpBytesValue = { bytesValue: string }\ntype OtlpArrayValue = { arrayValue: { values: OtlpAnyValue[] } }\ntype OtlpKvListValue = { kvlistValue: { values: OtlpKeyValue[] } }\n\ntype OtlpAnyValue = OtlpStringValue | OtlpBoolValue | OtlpIntValue | OtlpDoubleValue | OtlpBytesValue | OtlpArrayValue | OtlpKvListValue\n\ntype OtlpKeyValue = {\n key: string\n value: OtlpAnyValue\n}\n\ntype OtlpResource = {\n attributes: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpInstrumentationScope = {\n name: string\n version?: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\n/** https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L103 */\ntype OtlpSpanKind = 0 | 1 | 2 | 3 | 4 | 5\n\n/** 0 = STATUS_CODE_UNSET, 1 = STATUS_CODE_OK, 2 = STATUS_CODE_ERROR */\ntype OtlpStatusCode = 0 | 1 | 2\n\ntype OtlpStatus = {\n code: OtlpStatusCode\n message?: string\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n traceState?: string\n parentSpanId?: string\n name: string\n kind: OtlpSpanKind\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n events?: OtlpSpanEvent[]\n droppedEventsCount?: number\n links?: OtlpSpanLink[]\n droppedLinksCount?: number\n status?: OtlpStatus\n}\n\ntype OtlpSpanEvent = {\n timeUnixNano: string\n name: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpSpanLink = {\n traceId: string\n spanId: string\n traceState?: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpScopeSpans = {\n scope: OtlpInstrumentationScope\n spans: OtlpSpan[]\n schemaUrl?: string\n}\n\ntype OtlpResourceSpans = {\n resource: OtlpResource\n scopeSpans: OtlpScopeSpans[]\n schemaUrl?: string\n}\n\n/** Root payload sent to POST /v1/traces */\nexport type OtlpExportTraceServiceRequest = {\n resourceSpans: OtlpResourceSpans[]\n}\n\n// ---------------------------------------------------------------------------\n\nexport type TelemetryPlugin = {\n name: string\n options: Record<string, unknown>\n}\n\nexport type TelemetryEvent = {\n command: string\n kubbVersion: string\n nodeVersion: string\n platform: string\n ci: boolean\n plugins: TelemetryPlugin[]\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Detect whether the current process is running inside a CI environment by\n * checking the well-known environment variables set by all major CI systems.\n */\nexport function isCi(): boolean {\n return !!(\n (\n process.env['CI'] || // Generic (GitHub Actions, GitLab CI, CircleCI, Travis CI, etc.)\n process.env['GITHUB_ACTIONS'] || // GitHub Actions\n process.env['GITLAB_CI'] || // GitLab CI\n process.env['BITBUCKET_BUILD_NUMBER'] || // Bitbucket Pipelines\n process.env['JENKINS_URL'] || // Jenkins\n process.env['CIRCLECI'] || // CircleCI\n process.env['TRAVIS'] || // Travis CI\n process.env['TEAMCITY_VERSION'] || // TeamCity\n process.env['BUILDKITE'] || // Buildkite\n process.env['TF_BUILD']\n ) // Azure Pipelines\n )\n}\n\n/**\n * Check if telemetry is disabled via DO_NOT_TRACK or KUBB_DISABLE_TELEMETRY.\n * Respects the standard DO_NOT_TRACK convention used across development tools.\n */\nexport function isTelemetryDisabled(): 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 * Convert a TelemetryEvent into an OTLP-compatible JSON trace payload.\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: 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.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(\n (p): OtlpKvListValue => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n { key: 'options', value: { stringValue: JSON.stringify({ ...p.options, usedEnumNames: undefined }) } },\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-cli' } },\n { key: 'service.version', value: { stringValue: event.kubbVersion } },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-cli', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1 satisfies OtlpSpanKind,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: { code: (event.status === 'success' ? 1 : 2) satisfies OtlpStatusCode },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint.\n * Respects DO_NOT_TRACK and KUBB_DISABLE_TELEMETRY environment variables.\n * Fails silently to never interrupt the generation process.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isTelemetryDisabled()) {\n return\n }\n\n await executeIfOnline(async () => {\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-cli',\n },\n body: JSON.stringify(buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently – telemetry must never break the CLI\n }\n })\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n * No file paths, OpenAPI specs, or secrets are included.\n */\nexport function buildTelemetryEvent(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\n kubbVersion: string\n plugins?: 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] ?? 'unknown',\n platform: os.platform(),\n ci: isCi(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n"],"mappings":";;;;;;AAKA,MAAM,gBAAgB;;;;;AAuHtB,SAAgB,OAAgB;AAC9B,QAAO,CAAC,EAEJ,QAAQ,IAAI,SACZ,QAAQ,IAAI,qBACZ,QAAQ,IAAI,gBACZ,QAAQ,IAAI,6BACZ,QAAQ,IAAI,kBACZ,QAAQ,IAAI,eACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI,uBACZ,QAAQ,IAAI,gBACZ,QAAQ,IAAI;;;;;;AASlB,SAAgB,sBAA+B;AAC7C,QACE,QAAQ,IAAI,oBAAoB,OAChC,QAAQ,IAAI,oBAAoB,UAChC,QAAQ,IAAI,8BAA8B,OAC1C,QAAQ,IAAI,8BAA8B;;;;;;AAQ9C,SAAgB,iBAAiB,OAAsD;CACrF,MAAM,UAAU,YAAY,GAAG,CAAC,SAAS,MAAM;CAC/C,MAAM,SAAS,YAAY,EAAE,CAAC,SAAS,MAAM;CAC7C,MAAM,YAAY,OAAO,KAAK,KAAK,CAAC,GAAG;CACvC,MAAM,cAAc,YAAY,OAAO,MAAM,SAAS,GAAG;CAEzD,MAAM,aAA6B;EACjC;GAAE,KAAK;GAAgB,OAAO,EAAE,aAAa,MAAM,SAAS;GAAE;EAC9D;GAAE,KAAK;GAAgB,OAAO,EAAE,aAAa,MAAM,aAAa;GAAE;EAClE;GAAE,KAAK;GAAqB,OAAO,EAAE,aAAa,MAAM,aAAa;GAAE;EACvE;GAAE,KAAK;GAAiB,OAAO,EAAE,aAAa,MAAM,UAAU;GAAE;EAChE;GAAE,KAAK;GAAW,OAAO,EAAE,WAAW,MAAM,IAAI;GAAE;EAClD;GAAE,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;GAGb;;;;;;AAOJ,SAAgB,oBAAoB,SAOjB;CACjB,MAAM,CAAC,SAAS,eAAe,QAAQ,OAAO,QAAQ,QAAQ;CAC9D,MAAM,WAAW,KAAK,MAAM,UAAU,MAAO,cAAc,IAAI;AAE/D,QAAO;EACL,SAAS,QAAQ;EACjB,aAAa,QAAQ;EACrB,aAAa,QAAQ,SAAS,KAAK,MAAM,IAAI,CAAC,MAAM;EACpD,UAAU,GAAG,UAAU;EACvB,IAAI,MAAM;EACV,SAAS,QAAQ,WAAW,EAAE;EAC9B;EACA,cAAc,QAAQ,gBAAgB;EACtC,QAAQ,QAAQ;EACjB"}
@@ -1,13 +1,11 @@
1
- const require_chunk = require('./chunk-CNbaEX1y.cjs');
2
- const require_package = require('./package-BuRPi56s.cjs');
3
- const require_telemetry = require('./telemetry-BcdCgNDv.cjs');
1
+ const require_chunk = require("./chunk-ByKO4r7w.cjs");
2
+ const require_package = require("./package-CKryUEad.cjs");
3
+ const require_telemetry = require("./telemetry-BDSSqUiG.cjs");
4
4
  let citty = require("citty");
5
5
  let node_process = require("node:process");
6
6
  node_process = require_chunk.__toESM(node_process);
7
- let jiti = require("jiti");
8
-
9
7
  //#region src/commands/validate.ts
10
- const jiti$1 = (0, jiti.createJiti)(require("url").pathToFileURL(__filename).href, { sourceMaps: true });
8
+ const jiti$1 = (0, require("jiti").createJiti)(require("url").pathToFileURL(__filename).href, { sourceMaps: true });
11
9
  const command = (0, citty.defineCommand)({
12
10
  meta: {
13
11
  name: "validate",
@@ -62,7 +60,7 @@ const command = (0, citty.defineCommand)({
62
60
  }
63
61
  }
64
62
  });
65
-
66
63
  //#endregion
67
64
  exports.default = command;
68
- //# sourceMappingURL=validate-BAoV_Yr0.cjs.map
65
+
66
+ //# sourceMappingURL=validate-Cl24nvUu.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-BAoV_Yr0.cjs","names":["jiti","process","sendTelemetry","buildTelemetryEvent","version"],"sources":["../src/commands/validate.ts"],"sourcesContent":["import process from 'node:process'\nimport type { ArgsDef } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\nimport { createJiti } from 'jiti'\nimport { version } from '../../package.json'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\nconst jiti = createJiti(import.meta.url, {\n sourceMaps: true,\n})\n\nconst args = {\n input: {\n type: 'string',\n description: 'Path to Swagger/OpenAPI file',\n alias: 'i',\n },\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nconst command = defineCommand({\n meta: {\n name: 'validate',\n description: 'Validate a Swagger/OpenAPI file',\n },\n args,\n async run(commandContext) {\n const { args } = commandContext\n\n if (args.help) {\n return showUsage(command)\n }\n\n if (args.input) {\n let mod: any\n try {\n mod = await jiti.import('@kubb/oas', { default: true })\n } catch (_e) {\n console.error(`Import of '@kubb/oas' is required to do validation`)\n process.exit(1)\n }\n\n const { parse } = mod\n const hrStart = process.hrtime()\n try {\n const oas = await parse(args.input)\n await oas.validate()\n\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'success' }))\n console.log('✅ Validation success')\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'failed' }))\n console.error('❌ Validation failed')\n console.log((error as Error)?.message)\n process.exit(1)\n }\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;;;;AAOA,MAAMA,6EAAmC,EACvC,YAAY,MACb,CAAC;AAgBF,MAAM,mCAAwB;CAC5B,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAnBW;EACX,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACR;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACF;CAQC,MAAM,IAAI,gBAAgB;EACxB,MAAM,EAAE,SAAS;AAEjB,MAAI,KAAK,KACP,6BAAiB,QAAQ;AAG3B,MAAI,KAAK,OAAO;GACd,IAAI;AACJ,OAAI;AACF,UAAM,MAAMA,OAAK,OAAO,aAAa,EAAE,SAAS,MAAM,CAAC;YAChD,IAAI;AACX,YAAQ,MAAM,qDAAqD;AACnE,yBAAQ,KAAK,EAAE;;GAGjB,MAAM,EAAE,UAAU;GAClB,MAAM,UAAUC,qBAAQ,QAAQ;AAChC,OAAI;AAEF,WADY,MAAM,MAAM,KAAK,MAAM,EACzB,UAAU;AAEpB,UAAMC,gCAAcC,sCAAoB;KAAE,SAAS;KAAY,aAAaC;KAAS;KAAS,QAAQ;KAAW,CAAC,CAAC;AACnH,YAAQ,IAAI,uBAAuB;YAC5B,OAAO;AACd,UAAMF,gCAAcC,sCAAoB;KAAE,SAAS;KAAY,aAAaC;KAAS;KAAS,QAAQ;KAAU,CAAC,CAAC;AAClH,YAAQ,MAAM,sBAAsB;AACpC,YAAQ,IAAK,OAAiB,QAAQ;AACtC,yBAAQ,KAAK,EAAE;;;;CAItB,CAAC"}
1
+ {"version":3,"file":"validate-Cl24nvUu.cjs","names":["jiti","process","sendTelemetry","buildTelemetryEvent","version"],"sources":["../src/commands/validate.ts"],"sourcesContent":["import process from 'node:process'\nimport type { ArgsDef } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\nimport { createJiti } from 'jiti'\nimport { version } from '../../package.json'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\nconst jiti = createJiti(import.meta.url, {\n sourceMaps: true,\n})\n\nconst args = {\n input: {\n type: 'string',\n description: 'Path to Swagger/OpenAPI file',\n alias: 'i',\n },\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nconst command = defineCommand({\n meta: {\n name: 'validate',\n description: 'Validate a Swagger/OpenAPI file',\n },\n args,\n async run(commandContext) {\n const { args } = commandContext\n\n if (args.help) {\n return showUsage(command)\n }\n\n if (args.input) {\n let mod: any\n try {\n mod = await jiti.import('@kubb/oas', { default: true })\n } catch (_e) {\n console.error(`Import of '@kubb/oas' is required to do validation`)\n process.exit(1)\n }\n\n const { parse } = mod\n const hrStart = process.hrtime()\n try {\n const oas = await parse(args.input)\n await oas.validate()\n\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'success' }))\n console.log('✅ Validation success')\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'failed' }))\n console.error('❌ Validation failed')\n console.log((error as Error)?.message)\n process.exit(1)\n }\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;;AAOA,MAAMA,UAAAA,mBAAAA,YAAAA,QAAAA,MAAAA,CAAAA,cAAAA,WAAAA,CAAAA,MAAmC,EACvC,YAAY,MACb,CAAC;AAgBF,MAAM,WAAA,GAAA,MAAA,eAAwB;CAC5B,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAnBW;EACX,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACR;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACF;CAQC,MAAM,IAAI,gBAAgB;EACxB,MAAM,EAAE,SAAS;AAEjB,MAAI,KAAK,KACP,SAAA,GAAA,MAAA,WAAiB,QAAQ;AAG3B,MAAI,KAAK,OAAO;GACd,IAAI;AACJ,OAAI;AACF,UAAM,MAAMA,OAAK,OAAO,aAAa,EAAE,SAAS,MAAM,CAAC;YAChD,IAAI;AACX,YAAQ,MAAM,qDAAqD;AACnE,iBAAA,QAAQ,KAAK,EAAE;;GAGjB,MAAM,EAAE,UAAU;GAClB,MAAM,UAAUC,aAAAA,QAAQ,QAAQ;AAChC,OAAI;AAEF,WADY,MAAM,MAAM,KAAK,MAAM,EACzB,UAAU;AAEpB,UAAMC,kBAAAA,cAAcC,kBAAAA,oBAAoB;KAAE,SAAS;KAAY,aAAaC,gBAAAA;KAAS;KAAS,QAAQ;KAAW,CAAC,CAAC;AACnH,YAAQ,IAAI,uBAAuB;YAC5B,OAAO;AACd,UAAMF,kBAAAA,cAAcC,kBAAAA,oBAAoB;KAAE,SAAS;KAAY,aAAaC,gBAAAA;KAAS;KAAS,QAAQ;KAAU,CAAC,CAAC;AAClH,YAAQ,MAAM,sBAAsB;AACpC,YAAQ,IAAK,OAAiB,QAAQ;AACtC,iBAAA,QAAQ,KAAK,EAAE;;;;CAItB,CAAC"}
@@ -1,10 +1,9 @@
1
- import { t as __name } from "./chunk-DKWOrOAv.js";
2
- import { t as version } from "./package-CxCdHR6N.js";
3
- import { r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-4xNBLqQy.js";
1
+ import "./chunk--u3MIqq1.js";
2
+ import { t as version } from "./package-Drh57N7E.js";
3
+ import { r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-DYWvlxqs.js";
4
4
  import { defineCommand, showUsage } from "citty";
5
5
  import process from "node:process";
6
6
  import { createJiti } from "jiti";
7
-
8
7
  //#region src/commands/validate.ts
9
8
  const jiti = createJiti(import.meta.url, { sourceMaps: true });
10
9
  const command = defineCommand({
@@ -61,7 +60,7 @@ const command = defineCommand({
61
60
  }
62
61
  }
63
62
  });
64
-
65
63
  //#endregion
66
64
  export { command as default };
67
- //# sourceMappingURL=validate-CujTQNa8.js.map
65
+
66
+ //# sourceMappingURL=validate-DN-TyVLr.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-CujTQNa8.js","names":[],"sources":["../src/commands/validate.ts"],"sourcesContent":["import process from 'node:process'\nimport type { ArgsDef } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\nimport { createJiti } from 'jiti'\nimport { version } from '../../package.json'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\nconst jiti = createJiti(import.meta.url, {\n sourceMaps: true,\n})\n\nconst args = {\n input: {\n type: 'string',\n description: 'Path to Swagger/OpenAPI file',\n alias: 'i',\n },\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nconst command = defineCommand({\n meta: {\n name: 'validate',\n description: 'Validate a Swagger/OpenAPI file',\n },\n args,\n async run(commandContext) {\n const { args } = commandContext\n\n if (args.help) {\n return showUsage(command)\n }\n\n if (args.input) {\n let mod: any\n try {\n mod = await jiti.import('@kubb/oas', { default: true })\n } catch (_e) {\n console.error(`Import of '@kubb/oas' is required to do validation`)\n process.exit(1)\n }\n\n const { parse } = mod\n const hrStart = process.hrtime()\n try {\n const oas = await parse(args.input)\n await oas.validate()\n\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'success' }))\n console.log('✅ Validation success')\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'failed' }))\n console.error('❌ Validation failed')\n console.log((error as Error)?.message)\n process.exit(1)\n }\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;;;AAOA,MAAM,OAAO,WAAW,OAAO,KAAK,KAAK,EACvC,YAAY,MACb,CAAC;AAgBF,MAAM,UAAU,cAAc;CAC5B,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAnBW;EACX,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACR;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACF;CAQC,MAAM,IAAI,gBAAgB;EACxB,MAAM,EAAE,SAAS;AAEjB,MAAI,KAAK,KACP,QAAO,UAAU,QAAQ;AAG3B,MAAI,KAAK,OAAO;GACd,IAAI;AACJ,OAAI;AACF,UAAM,MAAM,KAAK,OAAO,aAAa,EAAE,SAAS,MAAM,CAAC;YAChD,IAAI;AACX,YAAQ,MAAM,qDAAqD;AACnE,YAAQ,KAAK,EAAE;;GAGjB,MAAM,EAAE,UAAU;GAClB,MAAM,UAAU,QAAQ,QAAQ;AAChC,OAAI;AAEF,WADY,MAAM,MAAM,KAAK,MAAM,EACzB,UAAU;AAEpB,UAAM,cAAc,oBAAoB;KAAE,SAAS;KAAY,aAAa;KAAS;KAAS,QAAQ;KAAW,CAAC,CAAC;AACnH,YAAQ,IAAI,uBAAuB;YAC5B,OAAO;AACd,UAAM,cAAc,oBAAoB;KAAE,SAAS;KAAY,aAAa;KAAS;KAAS,QAAQ;KAAU,CAAC,CAAC;AAClH,YAAQ,MAAM,sBAAsB;AACpC,YAAQ,IAAK,OAAiB,QAAQ;AACtC,YAAQ,KAAK,EAAE;;;;CAItB,CAAC"}
1
+ {"version":3,"file":"validate-DN-TyVLr.js","names":[],"sources":["../src/commands/validate.ts"],"sourcesContent":["import process from 'node:process'\nimport type { ArgsDef } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\nimport { createJiti } from 'jiti'\nimport { version } from '../../package.json'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\nconst jiti = createJiti(import.meta.url, {\n sourceMaps: true,\n})\n\nconst args = {\n input: {\n type: 'string',\n description: 'Path to Swagger/OpenAPI file',\n alias: 'i',\n },\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nconst command = defineCommand({\n meta: {\n name: 'validate',\n description: 'Validate a Swagger/OpenAPI file',\n },\n args,\n async run(commandContext) {\n const { args } = commandContext\n\n if (args.help) {\n return showUsage(command)\n }\n\n if (args.input) {\n let mod: any\n try {\n mod = await jiti.import('@kubb/oas', { default: true })\n } catch (_e) {\n console.error(`Import of '@kubb/oas' is required to do validation`)\n process.exit(1)\n }\n\n const { parse } = mod\n const hrStart = process.hrtime()\n try {\n const oas = await parse(args.input)\n await oas.validate()\n\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'success' }))\n console.log('✅ Validation success')\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'failed' }))\n console.error('❌ Validation failed')\n console.log((error as Error)?.message)\n process.exit(1)\n }\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;;AAOA,MAAM,OAAO,WAAW,OAAO,KAAK,KAAK,EACvC,YAAY,MACb,CAAC;AAgBF,MAAM,UAAU,cAAc;CAC5B,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAnBW;EACX,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACR;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACF;CAQC,MAAM,IAAI,gBAAgB;EACxB,MAAM,EAAE,SAAS;AAEjB,MAAI,KAAK,KACP,QAAO,UAAU,QAAQ;AAG3B,MAAI,KAAK,OAAO;GACd,IAAI;AACJ,OAAI;AACF,UAAM,MAAM,KAAK,OAAO,aAAa,EAAE,SAAS,MAAM,CAAC;YAChD,IAAI;AACX,YAAQ,MAAM,qDAAqD;AACnE,YAAQ,KAAK,EAAE;;GAGjB,MAAM,EAAE,UAAU;GAClB,MAAM,UAAU,QAAQ,QAAQ;AAChC,OAAI;AAEF,WADY,MAAM,MAAM,KAAK,MAAM,EACzB,UAAU;AAEpB,UAAM,cAAc,oBAAoB;KAAE,SAAS;KAAY,aAAa;KAAS;KAAS,QAAQ;KAAW,CAAC,CAAC;AACnH,YAAQ,IAAI,uBAAuB;YAC5B,OAAO;AACd,UAAM,cAAc,oBAAoB;KAAE,SAAS;KAAY,aAAa;KAAS;KAAS,QAAQ;KAAU,CAAC,CAAC;AAClH,YAAQ,MAAM,sBAAsB;AACpC,YAAQ,IAAK,OAAiB,QAAQ;AACtC,YAAQ,KAAK,EAAE;;;;CAItB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/cli",
3
- "version": "4.31.6",
3
+ "version": "4.32.1",
4
4
  "description": "Command-line interface for Kubb, enabling easy generation of TypeScript, React-Query, Zod, and other code from OpenAPI specifications.",
5
5
  "keywords": [
6
6
  "cli",
@@ -59,13 +59,13 @@
59
59
  "cosmiconfig": "^9.0.1",
60
60
  "jiti": "2.5.1",
61
61
  "tinyexec": "^1.0.2",
62
- "@kubb/core": "4.31.6"
62
+ "@kubb/core": "4.32.1"
63
63
  },
64
64
  "devDependencies": {
65
65
  "source-map-support": "^0.5.21",
66
- "@kubb/agent": "4.31.6",
67
- "@kubb/mcp": "4.31.6",
68
- "@kubb/oas": "4.31.6"
66
+ "@kubb/agent": "4.32.1",
67
+ "@kubb/mcp": "4.32.1",
68
+ "@kubb/oas": "4.32.1"
69
69
  },
70
70
  "engines": {
71
71
  "node": ">=20"
@@ -46,12 +46,11 @@ type StartServerProps = {
46
46
  port: number
47
47
  host: string
48
48
  configPath: string
49
- noCache: boolean
50
49
  allowWrite: boolean
51
50
  allowAll: boolean
52
51
  }
53
52
 
54
- async function startServer({ port, host, configPath, noCache, allowWrite, allowAll }: StartServerProps): Promise<void> {
53
+ async function startServer({ port, host, configPath, allowWrite, allowAll }: StartServerProps): Promise<void> {
55
54
  try {
56
55
  // Load .env file into process.env using Node.js built-in (v20.12.0+)
57
56
  try {
@@ -73,7 +72,6 @@ async function startServer({ port, host, configPath, noCache, allowWrite, allowA
73
72
  // kubb env
74
73
  const KUBB_AGENT_ROOT = process.env.KUBB_AGENT_ROOT || process.cwd()
75
74
  const KUBB_AGENT_CONFIG = process.env.KUBB_AGENT_CONFIG || configPath || 'kubb.config.ts'
76
- const KUBB_AGENT_NO_CACHE = noCache ? 'true' : 'false'
77
75
  const KUBB_AGENT_ALLOW_WRITE = allowAll || allowWrite ? 'true' : (process.env.KUBB_AGENT_ALLOW_WRITE ?? 'false')
78
76
  const KUBB_AGENT_ALLOW_ALL = allowAll ? 'true' : (process.env.KUBB_AGENT_ALLOW_ALL ?? 'false')
79
77
  const KUBB_AGENT_TOKEN = process.env.KUBB_AGENT_TOKEN
@@ -86,7 +84,6 @@ async function startServer({ port, host, configPath, noCache, allowWrite, allowA
86
84
  HOST,
87
85
  KUBB_AGENT_ROOT,
88
86
  KUBB_AGENT_CONFIG,
89
- KUBB_AGENT_NO_CACHE,
90
87
  KUBB_AGENT_ALLOW_WRITE,
91
88
  KUBB_AGENT_ALLOW_ALL,
92
89
  KUBB_AGENT_TOKEN,
@@ -98,9 +95,6 @@ async function startServer({ port, host, configPath, noCache, allowWrite, allowA
98
95
  clack.log.info(styleText('dim', `Config: ${KUBB_AGENT_CONFIG}`))
99
96
  clack.log.info(styleText('dim', `Host: ${HOST}`))
100
97
  clack.log.info(styleText('dim', `Port: ${PORT}`))
101
- if (noCache) {
102
- clack.log.info(styleText('dim', 'Session caching: disabled'))
103
- }
104
98
  if (!KUBB_AGENT_ALLOW_WRITE && !KUBB_AGENT_ALLOW_ALL) {
105
99
  clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))
106
100
  }
@@ -130,11 +124,10 @@ const command = defineCommand({
130
124
  const configPath = path.resolve(process.cwd(), args.config || 'kubb.config.ts')
131
125
  const port = args.port ? Number.parseInt(args.port, 10) : 0
132
126
  const host = args.host
133
- const noCache = args['no-cache']
134
127
  const allowWrite = args['allow-write']
135
128
  const allowAll = args['allow-all']
136
129
 
137
- startServer({ port, host, configPath, noCache, allowWrite, allowAll })
130
+ startServer({ port, host, configPath, allowWrite, allowAll })
138
131
  await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'success' }))
139
132
  } catch (error) {
140
133
  await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'failed' }))
@@ -1,12 +0,0 @@
1
-
2
- //#region package.json
3
- var version = "4.31.6";
4
-
5
- //#endregion
6
- Object.defineProperty(exports, 'version', {
7
- enumerable: true,
8
- get: function () {
9
- return version;
10
- }
11
- });
12
- //# sourceMappingURL=package-BuRPi56s.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-BuRPi56s.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,6 +0,0 @@
1
- //#region package.json
2
- var version = "4.31.6";
3
-
4
- //#endregion
5
- export { version as t };
6
- //# sourceMappingURL=package-CxCdHR6N.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-CxCdHR6N.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"start-DFNsdJzA.cjs","names":["path","process","sendTelemetry","buildTelemetryEvent","version"],"sources":["../src/commands/agent/start.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport path from 'node:path'\nimport * as process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport type { ArgsDef } from 'citty'\nimport { defineCommand } from 'citty'\nimport { version } from '../../../package.json'\nimport { buildTelemetryEvent, sendTelemetry } from '../../utils/telemetry.ts'\n\nconst args = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n alias: 'c',\n },\n port: {\n type: 'string',\n description: 'Port for the server. If not specified, an available port is automatically selected.',\n alias: 'p',\n },\n host: {\n type: 'string',\n description: 'Host for the server',\n default: 'localhost',\n },\n 'no-cache': {\n type: 'boolean',\n description: 'Disable session caching',\n default: false,\n },\n 'allow-write': {\n type: 'boolean',\n description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',\n default: false,\n },\n 'allow-all': {\n type: 'boolean',\n description: 'Grant all permissions (implies --allow-write).',\n default: false,\n },\n} as const satisfies ArgsDef\n\ntype StartServerProps = {\n port: number\n host: string\n configPath: string\n noCache: boolean\n allowWrite: boolean\n allowAll: boolean\n}\n\nasync function startServer({ port, host, configPath, noCache, allowWrite, allowAll }: StartServerProps): Promise<void> {\n try {\n // Load .env file into process.env using Node.js built-in (v20.12.0+)\n try {\n process.loadEnvFile()\n } catch {\n // .env file may not exist; ignore\n }\n\n // Resolve the @kubb/agent package path\n const agentPkgUrl = import.meta.resolve('@kubb/agent/package.json')\n const agentPkgPath = fileURLToPath(agentPkgUrl)\n const agentDir = path.dirname(agentPkgPath)\n const serverPath = path.join(agentDir, '.output', 'server', 'index.mjs')\n\n // nitro env\n const PORT = process.env.PORT || (port === 0 ? '3000' : String(port))\n const HOST = process.env.HOST || host || '0.0.0.0'\n\n // kubb env\n const KUBB_AGENT_ROOT = process.env.KUBB_AGENT_ROOT || process.cwd()\n const KUBB_AGENT_CONFIG = process.env.KUBB_AGENT_CONFIG || configPath || 'kubb.config.ts'\n const KUBB_AGENT_NO_CACHE = noCache ? 'true' : 'false'\n const KUBB_AGENT_ALLOW_WRITE = allowAll || allowWrite ? 'true' : (process.env.KUBB_AGENT_ALLOW_WRITE ?? 'false')\n const KUBB_AGENT_ALLOW_ALL = allowAll ? 'true' : (process.env.KUBB_AGENT_ALLOW_ALL ?? 'false')\n const KUBB_AGENT_TOKEN = process.env.KUBB_AGENT_TOKEN\n const KUBB_AGENT_RETRY_TIMEOUT = process.env.KUBB_AGENT_RETRY_TIMEOUT || '30000'\n const KUBB_STUDIO_URL = process.env.KUBB_STUDIO_URL || 'https://studio.kubb.dev'\n\n // Set environment variables\n const env = {\n PORT,\n HOST,\n KUBB_AGENT_ROOT,\n KUBB_AGENT_CONFIG,\n KUBB_AGENT_NO_CACHE,\n KUBB_AGENT_ALLOW_WRITE,\n KUBB_AGENT_ALLOW_ALL,\n KUBB_AGENT_TOKEN,\n KUBB_AGENT_RETRY_TIMEOUT,\n KUBB_STUDIO_URL,\n }\n\n clack.log.step(styleText('cyan', 'Starting agent server...'))\n clack.log.info(styleText('dim', `Config: ${KUBB_AGENT_CONFIG}`))\n clack.log.info(styleText('dim', `Host: ${HOST}`))\n clack.log.info(styleText('dim', `Port: ${PORT}`))\n if (noCache) {\n clack.log.info(styleText('dim', 'Session caching: disabled'))\n }\n if (!KUBB_AGENT_ALLOW_WRITE && !KUBB_AGENT_ALLOW_ALL) {\n clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))\n }\n\n spawn('node', [serverPath], {\n env: { ...process.env, ...env },\n stdio: 'inherit',\n cwd: process.cwd(),\n })\n } catch (error) {\n console.error('Failed to start agent server:', error)\n process.exit(1)\n }\n}\n\nconst command = defineCommand({\n meta: {\n name: 'start',\n description: 'Start the Agent server',\n },\n args,\n async run(commandContext) {\n const { args } = commandContext\n const hrStart = process.hrtime()\n\n try {\n const configPath = path.resolve(process.cwd(), args.config || 'kubb.config.ts')\n const port = args.port ? Number.parseInt(args.port, 10) : 0\n const host = args.host\n const noCache = args['no-cache']\n const allowWrite = args['allow-write']\n const allowAll = args['allow-all']\n\n startServer({ port, host, configPath, noCache, allowWrite, allowAll })\n await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'success' }))\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'failed' }))\n clack.log.error(styleText('red', 'Failed to start agent server'))\n console.error(error)\n process.exit(1)\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;;;;;;;;;;AAWA,MAAM,OAAO;CACX,QAAQ;EACN,MAAM;EACN,aAAa;EACb,OAAO;EACR;CACD,MAAM;EACJ,MAAM;EACN,aAAa;EACb,OAAO;EACR;CACD,MAAM;EACJ,MAAM;EACN,aAAa;EACb,SAAS;EACV;CACD,YAAY;EACV,MAAM;EACN,aAAa;EACb,SAAS;EACV;CACD,eAAe;EACb,MAAM;EACN,aAAa;EACb,SAAS;EACV;CACD,aAAa;EACX,MAAM;EACN,aAAa;EACb,SAAS;EACV;CACF;AAWD,eAAe,YAAY,EAAE,MAAM,MAAM,YAAY,SAAS,YAAY,YAA6C;AACrH,KAAI;AAEF,MAAI;AACF,gBAAQ,aAAa;UACf;EAMR,MAAM,8CAD0B,QAAQ,2BAA2B,CACpB;EAC/C,MAAM,WAAWA,kBAAK,QAAQ,aAAa;EAC3C,MAAM,aAAaA,kBAAK,KAAK,UAAU,WAAW,UAAU,YAAY;EAGxE,MAAM,OAAOC,aAAQ,IAAI,SAAS,SAAS,IAAI,SAAS,OAAO,KAAK;EACpE,MAAM,OAAOA,aAAQ,IAAI,QAAQ,QAAQ;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AAK,OAAO,OAAO,SAAS,KAAK,MAAM,GAAG,GAAG;GAC1D,MAAM,OAAO,KAAK;GAClB,MAAM,UAAU,KAAK;GACrB,MAAM,aAAa,KAAK;GACxB,MAAM,WAAW,KAAK;AAEtB,eAAY;IAAE;IAAM;IAAM;IAAY;IAAS;IAAY;IAAU,CAAC;AACtE,SAAMC,gCAAcC,sCAAoB;IAAE,SAAS;IAAS,aAAaC;IAAS;IAAS,QAAQ;IAAW,CAAC,CAAC;WACzG,OAAO;AACd,SAAMF,gCAAcC,sCAAoB;IAAE,SAAS;IAAS,aAAaC;IAAS;IAAS,QAAQ;IAAU,CAAC,CAAC;AAC/G,kBAAM,IAAI,+BAAgB,OAAO,+BAA+B,CAAC;AACjE,WAAQ,MAAM,MAAM;AACpB,gBAAQ,KAAK,EAAE;;;CAGpB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"start-DiHg3Vn9.js","names":["process"],"sources":["../src/commands/agent/start.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport path from 'node:path'\nimport * as process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport type { ArgsDef } from 'citty'\nimport { defineCommand } from 'citty'\nimport { version } from '../../../package.json'\nimport { buildTelemetryEvent, sendTelemetry } from '../../utils/telemetry.ts'\n\nconst args = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n alias: 'c',\n },\n port: {\n type: 'string',\n description: 'Port for the server. If not specified, an available port is automatically selected.',\n alias: 'p',\n },\n host: {\n type: 'string',\n description: 'Host for the server',\n default: 'localhost',\n },\n 'no-cache': {\n type: 'boolean',\n description: 'Disable session caching',\n default: false,\n },\n 'allow-write': {\n type: 'boolean',\n description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',\n default: false,\n },\n 'allow-all': {\n type: 'boolean',\n description: 'Grant all permissions (implies --allow-write).',\n default: false,\n },\n} as const satisfies ArgsDef\n\ntype StartServerProps = {\n port: number\n host: string\n configPath: string\n noCache: boolean\n allowWrite: boolean\n allowAll: boolean\n}\n\nasync function startServer({ port, host, configPath, noCache, allowWrite, allowAll }: StartServerProps): Promise<void> {\n try {\n // Load .env file into process.env using Node.js built-in (v20.12.0+)\n try {\n process.loadEnvFile()\n } catch {\n // .env file may not exist; ignore\n }\n\n // Resolve the @kubb/agent package path\n const agentPkgUrl = import.meta.resolve('@kubb/agent/package.json')\n const agentPkgPath = fileURLToPath(agentPkgUrl)\n const agentDir = path.dirname(agentPkgPath)\n const serverPath = path.join(agentDir, '.output', 'server', 'index.mjs')\n\n // nitro env\n const PORT = process.env.PORT || (port === 0 ? '3000' : String(port))\n const HOST = process.env.HOST || host || '0.0.0.0'\n\n // kubb env\n const KUBB_AGENT_ROOT = process.env.KUBB_AGENT_ROOT || process.cwd()\n const KUBB_AGENT_CONFIG = process.env.KUBB_AGENT_CONFIG || configPath || 'kubb.config.ts'\n const KUBB_AGENT_NO_CACHE = noCache ? 'true' : 'false'\n const KUBB_AGENT_ALLOW_WRITE = allowAll || allowWrite ? 'true' : (process.env.KUBB_AGENT_ALLOW_WRITE ?? 'false')\n const KUBB_AGENT_ALLOW_ALL = allowAll ? 'true' : (process.env.KUBB_AGENT_ALLOW_ALL ?? 'false')\n const KUBB_AGENT_TOKEN = process.env.KUBB_AGENT_TOKEN\n const KUBB_AGENT_RETRY_TIMEOUT = process.env.KUBB_AGENT_RETRY_TIMEOUT || '30000'\n const KUBB_STUDIO_URL = process.env.KUBB_STUDIO_URL || 'https://studio.kubb.dev'\n\n // Set environment variables\n const env = {\n PORT,\n HOST,\n KUBB_AGENT_ROOT,\n KUBB_AGENT_CONFIG,\n KUBB_AGENT_NO_CACHE,\n KUBB_AGENT_ALLOW_WRITE,\n KUBB_AGENT_ALLOW_ALL,\n KUBB_AGENT_TOKEN,\n KUBB_AGENT_RETRY_TIMEOUT,\n KUBB_STUDIO_URL,\n }\n\n clack.log.step(styleText('cyan', 'Starting agent server...'))\n clack.log.info(styleText('dim', `Config: ${KUBB_AGENT_CONFIG}`))\n clack.log.info(styleText('dim', `Host: ${HOST}`))\n clack.log.info(styleText('dim', `Port: ${PORT}`))\n if (noCache) {\n clack.log.info(styleText('dim', 'Session caching: disabled'))\n }\n if (!KUBB_AGENT_ALLOW_WRITE && !KUBB_AGENT_ALLOW_ALL) {\n clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))\n }\n\n spawn('node', [serverPath], {\n env: { ...process.env, ...env },\n stdio: 'inherit',\n cwd: process.cwd(),\n })\n } catch (error) {\n console.error('Failed to start agent server:', error)\n process.exit(1)\n }\n}\n\nconst command = defineCommand({\n meta: {\n name: 'start',\n description: 'Start the Agent server',\n },\n args,\n async run(commandContext) {\n const { args } = commandContext\n const hrStart = process.hrtime()\n\n try {\n const configPath = path.resolve(process.cwd(), args.config || 'kubb.config.ts')\n const port = args.port ? Number.parseInt(args.port, 10) : 0\n const host = args.host\n const noCache = args['no-cache']\n const allowWrite = args['allow-write']\n const allowAll = args['allow-all']\n\n startServer({ port, host, configPath, noCache, allowWrite, allowAll })\n await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'success' }))\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'failed' }))\n clack.log.error(styleText('red', 'Failed to start agent server'))\n console.error(error)\n process.exit(1)\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;;;;;;;AAWA,MAAM,OAAO;CACX,QAAQ;EACN,MAAM;EACN,aAAa;EACb,OAAO;EACR;CACD,MAAM;EACJ,MAAM;EACN,aAAa;EACb,OAAO;EACR;CACD,MAAM;EACJ,MAAM;EACN,aAAa;EACb,SAAS;EACV;CACD,YAAY;EACV,MAAM;EACN,aAAa;EACb,SAAS;EACV;CACD,eAAe;EACb,MAAM;EACN,aAAa;EACb,SAAS;EACV;CACD,aAAa;EACX,MAAM;EACN,aAAa;EACb,S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