@kubb/core 5.0.0-beta.38 → 5.0.0-beta.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,141 +1,186 @@
1
1
  import { t as __name } from "./chunk-C0LytTxp.js";
2
- import { $ as Exclude, A as KubbFileProcessingUpdate, At as Parser, B as KubbLifecycleStartContext, Bt as RendererFactory, C as InputPath, Ct as LoggerContext, D as KubbConfigEndContext, Dt as FileProcessor, E as KubbBuildStartContext, Et as defineLogger, F as KubbGenerationStartContext, Ft as ReporterName, G as UserConfig, Gt as AdapterFactoryOptions, H as KubbSuccessContext, Ht as Storage, I as KubbHookEndContext, It as UserReporter, J as Generator, Jt as diagnosticCode, K as createKubb, Kt as AdapterSource, L as KubbHookStartContext, Lt as createReporter, M as KubbFilesProcessingStartContext, Mt as GenerationResult, N as KubbFilesProcessingUpdateContext, Nt as Reporter, O as KubbDiagnosticContext, Ot as FileProcessorHooks, P as KubbGenerationEndContext, Pt as ReporterContext, Q as FileManager, R as KubbHooks, Rt as DevtoolsOptions, S as InputData, St as Logger, T as KubbBuildEndContext, Tt as UserLogger, U as KubbWarnContext, Ut as createStorage, V as KubbPluginsEndContext, Vt as createRenderer, W as PossibleConfig, Wt as Adapter, X as defineGenerator, Xt as AsyncEventEmitter, Y as GeneratorContext, Yt as logLevel, Z as KubbDriver, _ as isUpdateDiagnostic, _t as ResolverFileParams, a as DiagnosticKind, at as NormalizedPlugin, b as CLIOptions, bt as Middleware, c as Diagnostics, ct as Plugin, d as ProblemDiagnostic, dt as BannerMeta, et as Group, f as SerializedDiagnostic, ft as ResolveBannerContext, g as isProblemDiagnostic, gt as ResolverContext, h as isPerformanceDiagnostic, ht as Resolver, i as DiagnosticError, it as KubbPluginStartContext, j as KubbFilesProcessingEndContext, jt as defineParser, k as KubbErrorContext, kt as ParsedFile, l as PerformanceDiagnostic, lt as PluginFactoryOptions, m as diagnosticCatalog, mt as ResolveOptionsContext, n as DiagnosticByCode, nt as KubbPluginEndContext, o as DiagnosticLocation, ot as Output, p as UpdateDiagnostic, pt as ResolveBannerFile, q as isInputPath, qt as createAdapter, r as DiagnosticDoc, rt as KubbPluginSetupContext, s as DiagnosticSeverity, st as Override, t as Diagnostic, tt as Include, u as ProblemCode, ut as definePlugin, v as narrowDiagnostic, vt as ResolverPathParams, w as Kubb, wt as LoggerOptions, x as Config, xt as defineMiddleware, y as BuildOutput, yt as defineResolver, z as KubbInfoContext, zt as Renderer } from "./diagnostics-CYfKPtbU.js";
2
+ import { $ as Override, A as KubbHookEndContext, At as logLevel, B as createKubb, Bt as AsyncEventEmitter, C as KubbErrorContext, Ct as createReporter, D as KubbFilesProcessingUpdateContext, Dt as LoggerOptions, E as KubbFilesProcessingStartContext, Et as LoggerContext, F as KubbPluginsEndContext, Ft as createStorage, G as Exclude, H as GeneratorContext, I as KubbSuccessContext, It as Adapter, J as KubbPluginEndContext, K as Group, L as KubbWarnContext, Lt as AdapterFactoryOptions, M as KubbHooks, Mt as RendererFactory, N as KubbInfoContext, Nt as createRenderer, O as KubbGenerationEndContext, Ot as UserLogger, P as KubbLifecycleStartContext, Pt as Storage, Q as Output, R as PossibleConfig, Rt as AdapterSource, S as KubbDiagnosticContext, St as UserReporter, T as KubbFilesProcessingEndContext, Tt as Logger, U as defineGenerator, V as Generator, W as KubbDriver, X as KubbPluginStartContext, Y as KubbPluginSetupContext, Z as NormalizedPlugin, _ as InputPath, _t as defineParser, a as DiagnosticLocation, at as ResolveBannerFile, b as KubbBuildStartContext, bt as ReporterContext, c as PerformanceDiagnostic, ct as ResolverContext, d as SerializedDiagnostic, dt as defineResolver, et as Plugin, f as UpdateDiagnostic, ft as Middleware, g as InputData, gt as Parser, h as Config, ht as ParsedFile, i as DiagnosticKind, it as ResolveBannerContext, j as KubbHookStartContext, jt as Renderer, k as KubbGenerationStartContext, kt as defineLogger, l as ProblemCode, lt as ResolverFileParams, m as CLIOptions, mt as FileProcessorHooks, n as DiagnosticByCode, nt as definePlugin, o as DiagnosticSeverity, ot as ResolveOptionsContext, p as BuildOutput, pt as defineMiddleware, q as Include, r as DiagnosticDoc, rt as BannerMeta, s as Diagnostics, st as Resolver, t as Diagnostic, tt as PluginFactoryOptions, u as ProblemDiagnostic, ut as ResolverPathParams, v as Kubb, vt as GenerationResult, w as KubbFileProcessingUpdate, wt as selectReporters, x as KubbConfigEndContext, xt as ReporterName, y as KubbBuildEndContext, yt as Reporter, z as UserConfig, zt as createAdapter } from "./diagnostics-DhfW8YpT.js";
3
3
  import * as ast from "@kubb/ast";
4
4
 
5
- //#region ../../internals/utils/src/urlPath.d.ts
6
- type URLObject = {
7
- /**
8
- * The resolved URL string (Express-style or template literal, depending on context).
9
- */
10
- url: string;
11
- /**
12
- * Extracted path parameters as a key-value map, or `undefined` when the path has none.
13
- */
14
- params?: Record<string, string>;
5
+ //#region src/reporters/cliReporter.d.ts
6
+ /**
7
+ * The default `cli` reporter. Renders the {@link Report} for each config as it finishes, independent
8
+ * of the live logger view. Suppressed at `silent`; the `verbose` level adds the per-plugin timings.
9
+ */
10
+ declare const cliReporter: Reporter;
11
+ //#endregion
12
+ //#region src/reporters/fileReporter.d.ts
13
+ /**
14
+ * The `file` reporter. Writes a config's {@link Report} to `.kubb/kubb-<name>-<timestamp>.log` as a
15
+ * plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same counts the
16
+ * cli and json reporters expose, a `## Problems` section in the miette block format, and a
17
+ * `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`), replacing the
18
+ * old `--debug` flag.
19
+ *
20
+ * @note Unlike the streaming logger it replaced, it captures the collected diagnostics once a
21
+ * config finishes, not the live `kubb:info`/`kubb:plugin` event stream. Color is stripped so the
22
+ * file stays plain text even when the run is attached to a TTY.
23
+ */
24
+ declare const fileReporter: Reporter;
25
+ //#endregion
26
+ //#region src/reporters/jsonReporter.d.ts
27
+ /**
28
+ * The `json` reporter. `report` returns one config's {@link Report}, which {@link createReporter}
29
+ * buffers, and `drain` writes them as a single pretty-printed JSON array on `kubb:lifecycle:end`.
30
+ * Buffering keeps a multi-config run one valid JSON document on stdout instead of concatenated
31
+ * objects that would break `jq .`. The terminal reporter is suppressed while `json` is active so
32
+ * stdout stays valid JSON.
33
+ */
34
+ declare const jsonReporter: Reporter;
35
+ //#endregion
36
+ //#region src/Telemetry.d.ts
37
+ type OtlpStringValue = {
38
+ stringValue: string;
15
39
  };
16
- type ObjectOptions = {
17
- /**
18
- * Controls whether the `url` is rendered as an Express path or a template literal.
19
- * @default 'path'
20
- */
21
- type?: 'path' | 'template';
22
- /**
23
- * Optional transform applied to each extracted parameter name.
24
- */
25
- replacer?: (pathParam: string) => string;
26
- /**
27
- * When `true`, the result is serialized to a string expression instead of a plain object.
28
- */
29
- stringify?: boolean;
40
+ type OtlpBoolValue = {
41
+ boolValue: boolean;
42
+ };
43
+ type OtlpIntValue = {
44
+ intValue: number;
45
+ };
46
+ type OtlpDoubleValue = {
47
+ doubleValue: number;
48
+ };
49
+ type OtlpBytesValue = {
50
+ bytesValue: string;
51
+ };
52
+ type OtlpArrayValue = {
53
+ arrayValue: {
54
+ values: Array<OtlpAnyValue>;
55
+ };
56
+ };
57
+ type OtlpKvListValue = {
58
+ kvlistValue: {
59
+ values: Array<OtlpKeyValue>;
60
+ };
61
+ };
62
+ type OtlpAnyValue = OtlpStringValue | OtlpBoolValue | OtlpIntValue | OtlpDoubleValue | OtlpBytesValue | OtlpArrayValue | OtlpKvListValue;
63
+ type OtlpKeyValue = {
64
+ key: string;
65
+ value: OtlpAnyValue;
66
+ };
67
+ type OtlpResource = {
68
+ attributes: Array<OtlpKeyValue>;
69
+ droppedAttributesCount?: number;
70
+ };
71
+ type OtlpInstrumentationScope = {
72
+ name: string;
73
+ version?: string;
74
+ attributes?: Array<OtlpKeyValue>;
75
+ droppedAttributesCount?: number;
76
+ };
77
+ /** https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L103 */
78
+ type OtlpSpanKind = 0 | 1 | 2 | 3 | 4 | 5;
79
+ /** 0 = STATUS_CODE_UNSET, 1 = STATUS_CODE_OK, 2 = STATUS_CODE_ERROR */
80
+ type OtlpStatusCode = 0 | 1 | 2;
81
+ type OtlpStatus = {
82
+ code: OtlpStatusCode;
83
+ message?: string;
84
+ };
85
+ type OtlpSpan = {
86
+ traceId: string;
87
+ spanId: string;
88
+ traceState?: string;
89
+ parentSpanId?: string;
90
+ name: string;
91
+ kind: OtlpSpanKind;
92
+ startTimeUnixNano: string;
93
+ endTimeUnixNano: string;
94
+ attributes?: Array<OtlpKeyValue>;
95
+ droppedAttributesCount?: number;
96
+ events?: Array<OtlpSpanEvent>;
97
+ droppedEventsCount?: number;
98
+ links?: Array<OtlpSpanLink>;
99
+ droppedLinksCount?: number;
100
+ status?: OtlpStatus;
101
+ };
102
+ type OtlpSpanEvent = {
103
+ timeUnixNano: string;
104
+ name: string;
105
+ attributes?: Array<OtlpKeyValue>;
106
+ droppedAttributesCount?: number;
107
+ };
108
+ type OtlpSpanLink = {
109
+ traceId: string;
110
+ spanId: string;
111
+ traceState?: string;
112
+ attributes?: Array<OtlpKeyValue>;
113
+ droppedAttributesCount?: number;
114
+ };
115
+ type OtlpScopeSpans = {
116
+ scope: OtlpInstrumentationScope;
117
+ spans: Array<OtlpSpan>;
118
+ schemaUrl?: string;
119
+ };
120
+ type OtlpResourceSpans = {
121
+ resource: OtlpResource;
122
+ scopeSpans: Array<OtlpScopeSpans>;
123
+ schemaUrl?: string;
124
+ };
125
+ /** Root payload sent to POST /v1/traces */
126
+ type OtlpExportTraceServiceRequest = {
127
+ resourceSpans: Array<OtlpResourceSpans>;
30
128
  };
31
129
  /**
32
- * Supported identifier casing strategies for path parameters.
130
+ * Anonymous plugin name and options snapshot sent with each telemetry event.
33
131
  */
34
- type PathCasing = 'camelcase';
35
- type Options = {
132
+ type TelemetryPlugin = {
133
+ /**
134
+ * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.
135
+ */
136
+ name: string;
36
137
  /**
37
- * Casing strategy applied to path parameter names.
38
- * @default undefined (original identifier preserved)
138
+ * anonymized plugin options snapshot, values are included but cannot be traced back to the user.
39
139
  */
40
- casing?: PathCasing;
140
+ options: Record<string, unknown>;
141
+ };
142
+ type TelemetryEvent = {
143
+ command: string;
144
+ kubbVersion: string;
145
+ nodeVersion: string;
146
+ platform: string;
147
+ ci: boolean;
148
+ plugins: Array<TelemetryPlugin>;
149
+ duration: number;
150
+ filesCreated: number;
151
+ status: 'success' | 'failed';
41
152
  };
42
153
  /**
43
- * Parses and transforms an OpenAPI/Swagger path string into various URL formats.
44
- *
45
- * @example
46
- * const p = new URLPath('/pet/{petId}')
47
- * p.URL // '/pet/:petId'
48
- * p.template // '`/pet/${petId}`'
154
+ * Anonymous OTLP usage telemetry for the Kubb run. All methods are static, so call them as
155
+ * `Telemetry.build(...)`, `Telemetry.send(...)`, and `Telemetry.isDisabled()`. No file paths,
156
+ * OpenAPI specs, or secrets are ever included, and sending fails silently to never break a run.
49
157
  */
50
- declare class URLPath {
51
- #private;
158
+ declare class Telemetry {
52
159
  /**
53
- * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
160
+ * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
54
161
  */
55
- path: string;
56
- constructor(path: string, options?: Options);
57
- /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
58
- *
59
- * @example
60
- * ```ts
61
- * new URLPath('/pet/{petId}').URL // '/pet/:petId'
62
- * ```
63
- */
64
- get URL(): string;
65
- /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).
66
- *
67
- * @example
68
- * ```ts
69
- * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
70
- * new URLPath('/pet/{petId}').isURL // false
71
- * ```
72
- */
73
- get isURL(): boolean;
162
+ static isDisabled(): boolean;
74
163
  /**
75
- * Converts the OpenAPI path to a TypeScript template literal string.
76
- *
77
- * @example
78
- * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
79
- * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
80
- */
81
- get template(): string;
82
- /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.
83
- *
84
- * @example
85
- * ```ts
86
- * new URLPath('/pet/{petId}').object
87
- * // { url: '/pet/:petId', params: { petId: 'petId' } }
88
- * ```
164
+ * Build an anonymous telemetry payload from a completed generation run.
89
165
  */
90
- get object(): URLObject | string;
91
- /** Returns a map of path parameter names, or `undefined` when the path has no parameters.
92
- *
93
- * @example
94
- * ```ts
95
- * new URLPath('/pet/{petId}').params // { petId: 'petId' }
96
- * new URLPath('/pet').params // undefined
97
- * ```
98
- */
99
- get params(): Record<string, string> | undefined;
100
- toObject({
101
- type,
102
- replacer,
103
- stringify
104
- }?: ObjectOptions): URLObject | string;
166
+ static build(options: {
167
+ command: 'generate' | 'mcp' | 'validate' | 'agent';
168
+ kubbVersion: string;
169
+ plugins?: Array<TelemetryPlugin>;
170
+ hrStart: [number, number];
171
+ filesCreated?: number;
172
+ status: 'success' | 'failed';
173
+ }): TelemetryEvent;
105
174
  /**
106
- * Converts the OpenAPI path to a TypeScript template literal string.
107
- * An optional `replacer` can transform each extracted parameter name before interpolation.
108
- *
109
- * @example
110
- * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
175
+ * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.
176
+ * See https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/
111
177
  */
112
- toTemplateString({
113
- prefix,
114
- replacer
115
- }?: {
116
- prefix?: string | null;
117
- replacer?: (pathParam: string) => string;
118
- }): string;
178
+ static buildOtlpPayload(event: TelemetryEvent): OtlpExportTraceServiceRequest;
119
179
  /**
120
- * Extracts all `{param}` segments from the path and returns them as a key-value map.
121
- * An optional `replacer` transforms each parameter name in both key and value positions.
122
- * Returns `undefined` when no path parameters are found.
123
- *
124
- * @example
125
- * ```ts
126
- * new URLPath('/pet/{petId}/tag/{tagId}').getParams()
127
- * // { petId: 'petId', tagId: 'tagId' }
128
- * ```
129
- */
130
- getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined;
131
- /** Converts the OpenAPI path to Express-style colon syntax.
132
- *
133
- * @example
134
- * ```ts
135
- * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
136
- * ```
180
+ * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and
181
+ * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run.
137
182
  */
138
- toURLPath(): string;
183
+ static send(event: TelemetryEvent): Promise<void>;
139
184
  }
140
185
  //#endregion
141
186
  //#region src/storages/fsStorage.d.ts
@@ -188,5 +233,5 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Storag
188
233
  */
189
234
  declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
190
235
  //#endregion
191
- export { type Adapter, type AdapterFactoryOptions, type AdapterSource, AsyncEventEmitter, type BannerMeta, type BuildOutput, type CLIOptions, type Config, type DevtoolsOptions, type Diagnostic, type DiagnosticByCode, type DiagnosticDoc, DiagnosticError, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, FileManager, FileProcessor, type FileProcessorHooks, type GenerationResult, type Generator, type GeneratorContext, type Group, type Include, type InputData, type InputPath, type Kubb, type KubbBuildEndContext, type KubbBuildStartContext, type KubbConfigEndContext, type KubbDiagnosticContext, KubbDriver, type KubbErrorContext, type KubbFileProcessingUpdate, type KubbFilesProcessingEndContext, type KubbFilesProcessingStartContext, type KubbFilesProcessingUpdateContext, type KubbGenerationEndContext, type KubbGenerationStartContext, type KubbHookEndContext, type KubbHookStartContext, type KubbHooks, type KubbInfoContext, type KubbLifecycleStartContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type KubbPluginsEndContext, type KubbSuccessContext, type KubbWarnContext, type Logger, type LoggerContext, type LoggerOptions, type Middleware, type NormalizedPlugin, type Output, type Override, type ParsedFile, type Parser, type PerformanceDiagnostic, type Plugin, type PluginFactoryOptions, type PossibleConfig, type ProblemCode, type ProblemDiagnostic, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ResolveBannerContext, type ResolveBannerFile, type ResolveOptionsContext, type Resolver, type ResolverContext, type ResolverFileParams, type ResolverPathParams, type SerializedDiagnostic, type Storage, URLPath, type UpdateDiagnostic, type UserConfig, type UserLogger, type UserReporter, ast, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineLogger, defineMiddleware, defineParser, definePlugin, defineResolver, diagnosticCatalog, diagnosticCode, fsStorage, isInputPath, isPerformanceDiagnostic, isProblemDiagnostic, isUpdateDiagnostic, logLevel, memoryStorage, narrowDiagnostic };
236
+ export { type Adapter, type AdapterFactoryOptions, type AdapterSource, AsyncEventEmitter, type BannerMeta, type BuildOutput, type CLIOptions, type Config, type Diagnostic, type DiagnosticByCode, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type FileProcessorHooks, type GenerationResult, type Generator, type GeneratorContext, type Group, type Include, type InputData, type InputPath, type Kubb, type KubbBuildEndContext, type KubbBuildStartContext, type KubbConfigEndContext, type KubbDiagnosticContext, KubbDriver, type KubbErrorContext, type KubbFileProcessingUpdate, type KubbFilesProcessingEndContext, type KubbFilesProcessingStartContext, type KubbFilesProcessingUpdateContext, type KubbGenerationEndContext, type KubbGenerationStartContext, type KubbHookEndContext, type KubbHookStartContext, type KubbHooks, type KubbInfoContext, type KubbLifecycleStartContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type KubbPluginsEndContext, type KubbSuccessContext, type KubbWarnContext, type Logger, type LoggerContext, type LoggerOptions, type Middleware, type NormalizedPlugin, type Output, type Override, type ParsedFile, type Parser, type PerformanceDiagnostic, type Plugin, type PluginFactoryOptions, type PossibleConfig, type ProblemCode, type ProblemDiagnostic, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ResolveBannerContext, type ResolveBannerFile, type ResolveOptionsContext, type Resolver, type ResolverContext, type ResolverFileParams, type ResolverPathParams, type SerializedDiagnostic, type Storage, Telemetry, type UpdateDiagnostic, type UserConfig, type UserLogger, type UserReporter, ast, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineLogger, defineMiddleware, defineParser, definePlugin, defineResolver, fileReporter, fsStorage, jsonReporter, logLevel, memoryStorage, selectReporters };
192
237
  //# sourceMappingURL=index.d.ts.map