@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/{diagnostics-CYfKPtbU.d.ts → diagnostics-DhfW8YpT.d.ts} +289 -347
- package/dist/index.cjs +553 -174
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +164 -119
- package/dist/index.js +532 -149
- package/dist/index.js.map +1 -1
- package/dist/{KubbDriver-CyNF-NIb.js → memoryStorage-CNQTs-YG.js} +240 -157
- package/dist/memoryStorage-CNQTs-YG.js.map +1 -0
- package/dist/{KubbDriver-BYBUfOZ8.cjs → memoryStorage-DHi1d0To.cjs} +255 -196
- package/dist/memoryStorage-DHi1d0To.cjs.map +1 -0
- package/dist/mocks.cjs +36 -6
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +30 -3
- package/dist/mocks.js +33 -5
- package/dist/mocks.js.map +1 -1
- package/package.json +4 -4
- package/src/KubbDriver.ts +21 -65
- package/src/Telemetry.ts +278 -0
- package/src/constants.ts +14 -21
- package/src/createKubb.ts +22 -50
- package/src/createReporter.ts +43 -13
- package/src/defineGenerator.ts +2 -6
- package/src/defineLogger.ts +13 -1
- package/src/defineResolver.ts +3 -4
- package/src/diagnostics.ts +130 -61
- package/src/index.ts +8 -16
- package/src/mocks.ts +57 -2
- package/src/reporters/cliReporter.ts +90 -0
- package/src/reporters/fileReporter.ts +103 -0
- package/src/reporters/jsonReporter.ts +20 -0
- package/src/reporters/report.ts +85 -0
- package/src/types.ts +0 -1
- package/dist/KubbDriver-BYBUfOZ8.cjs.map +0 -1
- package/dist/KubbDriver-CyNF-NIb.js.map +0 -1
- package/src/devtools.ts +0 -53
package/dist/index.d.ts
CHANGED
|
@@ -1,141 +1,186 @@
|
|
|
1
1
|
import { t as __name } from "./chunk-C0LytTxp.js";
|
|
2
|
-
import { $ as
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
*
|
|
130
|
+
* Anonymous plugin name and options snapshot sent with each telemetry event.
|
|
33
131
|
*/
|
|
34
|
-
type
|
|
35
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
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
|
|
51
|
-
#private;
|
|
158
|
+
declare class Telemetry {
|
|
52
159
|
/**
|
|
53
|
-
*
|
|
160
|
+
* Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
|
|
54
161
|
*/
|
|
55
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
*
|
|
107
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
121
|
-
*
|
|
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
|
-
|
|
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
|
|
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
|