@kubb/core 5.11.6 → 5.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Enforce, FileNode, HttpMethod, ImportNode, InputMeta, InputNode, Macro, Node, OperationNode, SchemaNode, UserFileNode } from "@kubb/ast";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
+ import net from "node:net";
3
4
  //#region ../../internals/utils/src/promise.d.ts
4
5
  /** A value that may already be resolved or still pending.
5
6
  *
@@ -92,209 +93,215 @@ export declare function defineParser<TOptions extends object = object, TMeta ext
92
93
  */
93
94
  declare const diagnosticCatalog: {
94
95
  readonly unknown: {
95
- readonly code: "KUBB_UNKNOWN";
96
- readonly title: "Unknown error";
97
- readonly cause: "An error was thrown without a stable Kubb code, so it is reported as-is.";
98
- readonly fix: "Read the underlying message and stack. If it comes from a plugin or adapter, check its configuration; otherwise report it as a possible Kubb bug.";
96
+ readonly code: 'KUBB_UNKNOWN';
97
+ readonly title: 'Unknown error';
98
+ readonly cause: 'An error was thrown without a stable Kubb code, so it is reported as-is.';
99
+ readonly fix: 'Read the underlying message and stack. If it comes from a plugin or adapter, check its configuration; otherwise report it as a possible Kubb bug.';
99
100
  };
100
101
  readonly inputNotFound: {
101
- readonly code: "KUBB_INPUT_NOT_FOUND";
102
- readonly title: "Input not found";
103
- readonly cause: "The file set as `input` (or passed as `kubb generate PATH`) could not be read. A URL reports `KUBB_INPUT_REQUEST_FAILED` or `KUBB_INPUT_UNREACHABLE` instead.";
104
- readonly fix: "Check that the path exists and is readable, then set it as `input` or pass it on the CLI.";
102
+ readonly code: 'KUBB_INPUT_NOT_FOUND';
103
+ readonly title: 'Input not found';
104
+ readonly cause: 'The file set as `input` (or passed as `kubb generate PATH`) could not be read. A URL reports `KUBB_INPUT_REQUEST_FAILED` or `KUBB_INPUT_UNREACHABLE` instead.';
105
+ readonly fix: 'Check that the path exists and is readable, then set it as `input` or pass it on the CLI.';
105
106
  };
106
107
  readonly inputRequestFailed: {
107
- readonly code: "KUBB_INPUT_REQUEST_FAILED";
108
- readonly title: "Input request failed";
109
- readonly cause: "A URL set as `input` (or reached through a `$ref`) answered with a 4xx or 5xx status instead of the document.";
110
- readonly fix: "Open the URL to see what the server returns. A 401 or 403 needs credentials Kubb does not send, so download the document and point `input` at the local file. A 404 means the path is wrong, and a 5xx means the server itself failed.";
108
+ readonly code: 'KUBB_INPUT_REQUEST_FAILED';
109
+ readonly title: 'Input request failed';
110
+ readonly cause: 'A URL set as `input` (or reached through a `$ref`) answered with a 4xx or 5xx status instead of the document.';
111
+ readonly fix: 'Open the URL to see what the server returns. A 401 or 403 needs credentials Kubb does not send, so download the document and point `input` at the local file. A 404 means the path is wrong, and a 5xx means the server itself failed.';
111
112
  };
112
113
  readonly inputUnreachable: {
113
- readonly code: "KUBB_INPUT_UNREACHABLE";
114
- readonly title: "Input unreachable";
115
- readonly cause: "A URL set as `input` (or reached through a `$ref`) never answered, so the request failed before a status came back. A refused connection, an unknown host, an expired certificate, and a timeout all land here.";
116
- readonly fix: "Check that the host is running and reachable from this machine. For a local server, start it and confirm the port matches the one in `input`.";
114
+ readonly code: 'KUBB_INPUT_UNREACHABLE';
115
+ readonly title: 'Input unreachable';
116
+ readonly cause: 'A URL set as `input` (or reached through a `$ref`) never answered, so the request failed before a status came back. A refused connection, an unknown host, an expired certificate, and a timeout all land here.';
117
+ readonly fix: 'Check that the host is running and reachable from this machine. For a local server, start it and confirm the port matches the one in `input`.';
118
+ };
119
+ readonly gitInputFailed: {
120
+ readonly code: 'KUBB_GIT_INPUT_FAILED';
121
+ readonly title: 'Git input failed';
122
+ readonly cause: 'A git `input` (`git+<repo>#<ref>:<path>`) is malformed, or `git` could not fetch it: git is not installed, the repository or ref does not exist, or the credentials were refused.';
123
+ readonly fix: 'Write the input as `git+<repo>#<ref>:<path>`. Run `git fetch --depth 1 <repo> <ref>` yourself to see the git error, and set up a credential helper or SSH key for a private repository.';
117
124
  };
118
125
  readonly inputRequired: {
119
- readonly code: "KUBB_INPUT_REQUIRED";
120
- readonly title: "Input required";
121
- readonly cause: "An adapter is configured but no `input` was provided.";
122
- readonly fix: "Set `input` to a file path, a URL, an inline spec (JSON/YAML string), or a parsed object in your Kubb config.";
126
+ readonly code: 'KUBB_INPUT_REQUIRED';
127
+ readonly title: 'Input required';
128
+ readonly cause: 'An adapter is configured but no `input` was provided.';
129
+ readonly fix: 'Set `input` to a file path, a URL, an inline spec (JSON/YAML string), or a parsed object in your Kubb config.';
123
130
  };
124
131
  readonly legacyInput: {
125
- readonly code: "KUBB_LEGACY_INPUT";
126
- readonly title: "Legacy input shape";
127
- readonly cause: "`input` is a `{ path }` or `{ data }` wrapper, which v4 used to point at a document and v5 reads as the document itself.";
128
- readonly fix: "Unwrap it: `input: { path: \"./petStore.yaml\" }` becomes `input: \"./petStore.yaml\"`, and `input: { data: spec }` becomes `input: spec`.";
132
+ readonly code: 'KUBB_LEGACY_INPUT';
133
+ readonly title: 'Legacy input shape';
134
+ readonly cause: '`input` is a `{ path }` or `{ data }` wrapper, which v4 used to point at a document and v5 reads as the document itself.';
135
+ readonly fix: 'Unwrap it: `input: { path: "./petStore.yaml" }` becomes `input: "./petStore.yaml"`, and `input: { data: spec }` becomes `input: spec`.';
129
136
  };
130
137
  readonly invalidDocument: {
131
- readonly code: "KUBB_INVALID_DOCUMENT";
132
- readonly title: "Invalid document";
133
- readonly cause: "The `input` cannot be read as an OpenAPI or Swagger document: its JSON or YAML has a syntax error, it declares no `openapi` or `swagger` version field, or its version cannot be upgraded to OpenAPI 3.1.";
134
- readonly fix: "Fix the syntax at the reported line, and check that `input` points at the spec and not an HTML page. Point `input` at a Swagger 2.0, OpenAPI 3.0, or OpenAPI 3.1 document, and check that a passed object is the spec itself rather than a wrapper around it.";
138
+ readonly code: 'KUBB_INVALID_DOCUMENT';
139
+ readonly title: 'Invalid document';
140
+ readonly cause: 'The `input` cannot be read as an OpenAPI or Swagger document: its JSON or YAML has a syntax error, it declares no `openapi` or `swagger` version field, or its version cannot be upgraded to OpenAPI 3.1.';
141
+ readonly fix: 'Fix the syntax at the reported line, and check that `input` points at the spec and not an HTML page. Point `input` at a Swagger 2.0, OpenAPI 3.0, or OpenAPI 3.1 document, and check that a passed object is the spec itself rather than a wrapper around it.';
135
142
  };
136
143
  readonly invalidSpec: {
137
- readonly code: "KUBB_INVALID_SPEC";
138
- readonly title: "Invalid spec";
139
- readonly cause: "The document does not pass OpenAPI schema validation. Kubb still generates from it, but the output can be incomplete or wrong.";
140
- readonly fix: "Fix the reported problem in the spec. Run `kubb validate` to list every error, or set `validate: false` on the adapter to skip the check.";
144
+ readonly code: 'KUBB_INVALID_SPEC';
145
+ readonly title: 'Invalid spec';
146
+ readonly cause: 'The document does not pass OpenAPI schema validation. Kubb still generates from it, but the output can be incomplete or wrong.';
147
+ readonly fix: 'Fix the reported problem in the spec. Run `kubb validate` to list every error, or set `validate: false` on the adapter to skip the check.';
141
148
  };
142
149
  readonly refNotFound: {
143
- readonly code: "KUBB_REF_NOT_FOUND";
144
- readonly title: "Reference not found";
145
- readonly cause: "A `$ref` could not be resolved in the source document.";
146
- readonly fix: "Add the missing definition (for example under `components.schemas`) or fix the `$ref`. Run `kubb validate` to check the spec.";
150
+ readonly code: 'KUBB_REF_NOT_FOUND';
151
+ readonly title: 'Reference not found';
152
+ readonly cause: 'A `$ref` could not be resolved in the source document.';
153
+ readonly fix: 'Add the missing definition (for example under `components.schemas`) or fix the `$ref`. Run `kubb validate` to check the spec.';
147
154
  };
148
155
  readonly invalidServerVariable: {
149
- readonly code: "KUBB_INVALID_SERVER_VARIABLE";
150
- readonly title: "Invalid server variable";
151
- readonly cause: "A server variable value is not allowed by its `enum`.";
152
- readonly fix: "Use one of the values listed in the server variable `enum`, or update the spec.";
156
+ readonly code: 'KUBB_INVALID_SERVER_VARIABLE';
157
+ readonly title: 'Invalid server variable';
158
+ readonly cause: 'A server variable value is not allowed by its `enum`.';
159
+ readonly fix: 'Use one of the values listed in the server variable `enum`, or update the spec.';
153
160
  };
154
161
  readonly pluginNotFound: {
155
- readonly code: "KUBB_PLUGIN_NOT_FOUND";
156
- readonly title: "Plugin not found";
157
- readonly cause: "A plugin that another plugin depends on is missing from the config.";
158
- readonly fix: "Add the required plugin to the `plugins` array in kubb.config.ts, or remove the dependency on it.";
162
+ readonly code: 'KUBB_PLUGIN_NOT_FOUND';
163
+ readonly title: 'Plugin not found';
164
+ readonly cause: 'A plugin that another plugin depends on is missing from the config.';
165
+ readonly fix: 'Add the required plugin to the `plugins` array in kubb.config.ts, or remove the dependency on it.';
159
166
  };
160
167
  readonly incompatibleExtension: {
161
- readonly code: "KUBB_INCOMPATIBLE_EXTENSION";
162
- readonly title: "Incompatible extension";
163
- readonly cause: "A plugin sets `meta.compatibility.kubb` or `meta.compatibility.node` to a range the running Kubb or Node.js version does not satisfy.";
164
- readonly fix: "Upgrade Kubb or Node.js to a version in the range, or install a version of the plugin that supports your current Kubb and Node.js.";
168
+ readonly code: 'KUBB_INCOMPATIBLE_EXTENSION';
169
+ readonly title: 'Incompatible extension';
170
+ readonly cause: 'A plugin sets `meta.compatibility.kubb` or `meta.compatibility.node` to a range the running Kubb or Node.js version does not satisfy.';
171
+ readonly fix: 'Upgrade Kubb or Node.js to a version in the range, or install a version of the plugin that supports your current Kubb and Node.js.';
165
172
  };
166
173
  readonly missingDependency: {
167
- readonly code: "KUBB_MISSING_DEPENDENCY";
168
- readonly title: "Missing dependency";
169
- readonly cause: "A plugin lists another plugin in its `dependencies` record without `optional: true`, and the config does not include it.";
170
- readonly fix: "Add the missing plugin to the `plugins` array in kubb.config.ts.";
174
+ readonly code: 'KUBB_MISSING_DEPENDENCY';
175
+ readonly title: 'Missing dependency';
176
+ readonly cause: 'A plugin lists another plugin in its `dependencies` record without `optional: true`, and the config does not include it.';
177
+ readonly fix: 'Add the missing plugin to the `plugins` array in kubb.config.ts.';
171
178
  };
172
179
  readonly incompatibleDependency: {
173
- readonly code: "KUBB_INCOMPATIBLE_DEPENDENCY";
174
- readonly title: "Incompatible dependency";
180
+ readonly code: 'KUBB_INCOMPATIBLE_DEPENDENCY';
181
+ readonly title: 'Incompatible dependency';
175
182
  readonly cause: "A plugin's `dependencies` record sets a `version` range, and the configured plugin's `meta.version` falls outside it.";
176
- readonly fix: "Install a version of the dependency inside the range, or a version of the dependent plugin that supports the installed dependency.";
183
+ readonly fix: 'Install a version of the dependency inside the range, or a version of the dependent plugin that supports the installed dependency.';
177
184
  };
178
185
  readonly pluginFailed: {
179
- readonly code: "KUBB_PLUGIN_FAILED";
180
- readonly title: "Plugin failed";
181
- readonly cause: "A plugin threw while generating, or reported an error through `ctx.error`.";
182
- readonly fix: "Check the plugin options and the node at `at:`. If it is a bug, report it with the stack at `report:`.";
186
+ readonly code: 'KUBB_PLUGIN_FAILED';
187
+ readonly title: 'Plugin failed';
188
+ readonly cause: 'A plugin threw while generating, or reported an error through `ctx.error`.';
189
+ readonly fix: 'Check the plugin options and the node at `at:`. If it is a bug, report it with the stack at `report:`.';
183
190
  };
184
191
  readonly adapterFailed: {
185
- readonly code: "KUBB_ADAPTER_FAILED";
186
- readonly title: "Adapter failed";
187
- readonly cause: "The adapter threw an unexpected error while parsing the input.";
188
- readonly fix: "Check the input and the adapter options. If it is a bug, report it with the stack at `report:`.";
192
+ readonly code: 'KUBB_ADAPTER_FAILED';
193
+ readonly title: 'Adapter failed';
194
+ readonly cause: 'The adapter threw an unexpected error while parsing the input.';
195
+ readonly fix: 'Check the input and the adapter options. If it is a bug, report it with the stack at `report:`.';
189
196
  };
190
197
  readonly parserFailed: {
191
- readonly code: "KUBB_PARSER_FAILED";
192
- readonly title: "Parser failed";
193
- readonly cause: "A parser threw an unexpected error while printing a generated file.";
194
- readonly fix: "Check the parser options. If it is a bug, report it with the stack at `report:`.";
198
+ readonly code: 'KUBB_PARSER_FAILED';
199
+ readonly title: 'Parser failed';
200
+ readonly cause: 'A parser threw an unexpected error while printing a generated file.';
201
+ readonly fix: 'Check the parser options. If it is a bug, report it with the stack at `report:`.';
195
202
  };
196
203
  readonly pluginWarning: {
197
- readonly code: "KUBB_PLUGIN_WARNING";
198
- readonly title: "Plugin warning";
199
- readonly cause: "A plugin reported a non-fatal warning through `ctx.warn`.";
200
- readonly fix: "Review the message. It does not fail the build; adjust the plugin options or input if the warning is unwanted.";
204
+ readonly code: 'KUBB_PLUGIN_WARNING';
205
+ readonly title: 'Plugin warning';
206
+ readonly cause: 'A plugin reported a non-fatal warning through `ctx.warn`.';
207
+ readonly fix: 'Review the message. It does not fail the build; adjust the plugin options or input if the warning is unwanted.';
201
208
  };
202
209
  readonly pluginInfo: {
203
- readonly code: "KUBB_PLUGIN_INFO";
204
- readonly title: "Plugin info";
205
- readonly cause: "A plugin reported an informational message through `ctx.info`.";
206
- readonly fix: "Informational only. No action is required.";
210
+ readonly code: 'KUBB_PLUGIN_INFO';
211
+ readonly title: 'Plugin info';
212
+ readonly cause: 'A plugin reported an informational message through `ctx.info`.';
213
+ readonly fix: 'Informational only. No action is required.';
207
214
  };
208
215
  readonly noContext: {
209
- readonly code: "KUBB_NO_CONTEXT";
210
- readonly title: "No plugin context";
211
- readonly cause: "A `kubb/kit` composable such as `useKubb()` or `addGenerator()` ran outside the `setup` and `kubb:plugin:setup` of a plugin, so there is no plugin to apply it to.";
212
- readonly fix: "Call the composable inside `setup` or `kubb:plugin:setup`, including in code that setup awaits.";
216
+ readonly code: 'KUBB_NO_CONTEXT';
217
+ readonly title: 'No plugin context';
218
+ readonly cause: 'A `kubb/kit` composable such as `useKubb()` or `addGenerator()` ran outside the `setup` and `kubb:plugin:setup` of a plugin, so there is no plugin to apply it to.';
219
+ readonly fix: 'Call the composable inside `setup` or `kubb:plugin:setup`, including in code that setup awaits.';
213
220
  };
214
221
  readonly unsupportedFormat: {
215
- readonly code: "KUBB_UNSUPPORTED_FORMAT";
216
- readonly title: "Unsupported format";
217
- readonly cause: "A schema uses a `format` Kubb does not map to a specific type, so it falls back to the base type.";
218
- readonly fix: "Use a format Kubb supports, or handle the custom format with a parser or plugin.";
222
+ readonly code: 'KUBB_UNSUPPORTED_FORMAT';
223
+ readonly title: 'Unsupported format';
224
+ readonly cause: 'A schema uses a `format` Kubb does not map to a specific type, so it falls back to the base type.';
225
+ readonly fix: 'Use a format Kubb supports, or handle the custom format with a parser or plugin.';
219
226
  };
220
227
  readonly deprecated: {
221
- readonly code: "KUBB_DEPRECATED";
222
- readonly title: "Deprecated";
223
- readonly cause: "A referenced schema or operation is marked `deprecated`.";
224
- readonly fix: "Migrate off the deprecated definition if the warning is unwanted.";
228
+ readonly code: 'KUBB_DEPRECATED';
229
+ readonly title: 'Deprecated';
230
+ readonly cause: 'A referenced schema or operation is marked `deprecated`.';
231
+ readonly fix: 'Migrate off the deprecated definition if the warning is unwanted.';
225
232
  };
226
233
  readonly adapterRequired: {
227
- readonly code: "KUBB_ADAPTER_REQUIRED";
228
- readonly title: "Adapter required";
229
- readonly cause: "An action needs an adapter but none is configured.";
230
- readonly fix: "Set `adapter` in kubb.config.ts, for example `adapterOas()`.";
234
+ readonly code: 'KUBB_ADAPTER_REQUIRED';
235
+ readonly title: 'Adapter required';
236
+ readonly cause: 'An action needs an adapter but none is configured.';
237
+ readonly fix: 'Set `adapter` in kubb.config.ts, for example `adapterOas()`.';
231
238
  };
232
239
  readonly pathTraversal: {
233
- readonly code: "KUBB_PATH_TRAVERSAL";
234
- readonly title: "Path traversal";
235
- readonly cause: "A resolved output path escaped the output directory, which can stem from a path traversal in the spec or a misconfigured `group.name`.";
236
- readonly fix: "Keep generated paths within the output directory. Review the `group.name` function and the names coming from the spec.";
240
+ readonly code: 'KUBB_PATH_TRAVERSAL';
241
+ readonly title: 'Path traversal';
242
+ readonly cause: 'A resolved output path escaped the output directory, which can stem from a path traversal in the spec or a misconfigured `group.name`.';
243
+ readonly fix: 'Keep generated paths within the output directory. Review the `group.name` function and the names coming from the spec.';
237
244
  };
238
245
  readonly cleanRoot: {
239
- readonly code: "KUBB_CLEAN_ROOT";
240
- readonly title: "Clean targets the project root";
241
- readonly cause: "`output.clean` is enabled and `output.path` resolves to the project root or a parent of it, so cleaning would delete `kubb.config` and every source file.";
242
- readonly fix: "Point `output.path` at a subdirectory such as `./src/gen` so clean only removes generated code, or disable `output.clean`.";
246
+ readonly code: 'KUBB_CLEAN_ROOT';
247
+ readonly title: 'Clean targets the project root';
248
+ readonly cause: '`output.clean` is enabled and `output.path` resolves to the project root or a parent of it, so cleaning would delete `kubb.config` and every source file.';
249
+ readonly fix: 'Point `output.path` at a subdirectory such as `./src/gen` so clean only removes generated code, or disable `output.clean`.';
243
250
  };
244
251
  readonly invalidPluginOptions: {
245
- readonly code: "KUBB_INVALID_PLUGIN_OPTIONS";
246
- readonly title: "Invalid plugin options";
252
+ readonly code: 'KUBB_INVALID_PLUGIN_OPTIONS';
253
+ readonly title: 'Invalid plugin options';
247
254
  readonly cause: "A plugin was configured with options that cannot be honored, for example `output.mode: 'file'` paired with a `group` option.";
248
255
  readonly fix: "Fix the plugin options. A single-file output has nothing to group, so remove the `group` option or use `output.mode: 'directory'`.";
249
256
  };
250
257
  readonly postGenerateFailed: {
251
- readonly code: "KUBB_POST_GENERATE_FAILED";
252
- readonly title: "Post-generate command failed";
253
- readonly cause: "A post-generate command (`output.postGenerate`) exited with a non-zero status.";
254
- readonly fix: "Check the command is installed and correct, and run it manually to see the error.";
258
+ readonly code: 'KUBB_POST_GENERATE_FAILED';
259
+ readonly title: 'Post-generate command failed';
260
+ readonly cause: 'A post-generate command (`output.postGenerate`) exited with a non-zero status.';
261
+ readonly fix: 'Check the command is installed and correct, and run it manually to see the error.';
255
262
  };
256
263
  readonly formatFailed: {
257
- readonly code: "KUBB_FORMAT_FAILED";
258
- readonly title: "Format failed";
259
- readonly cause: "The formatter pass over the generated files failed.";
260
- readonly fix: "Check the formatter (oxfmt, biome, or prettier) is installed and its config is valid, then run it manually on the output.";
264
+ readonly code: 'KUBB_FORMAT_FAILED';
265
+ readonly title: 'Format failed';
266
+ readonly cause: 'The formatter pass over the generated files failed.';
267
+ readonly fix: 'Check the formatter (oxfmt, biome, or prettier) is installed and its config is valid, then run it manually on the output.';
261
268
  };
262
269
  readonly lintFailed: {
263
- readonly code: "KUBB_LINT_FAILED";
264
- readonly title: "Lint failed";
265
- readonly cause: "The linter pass over the generated files failed.";
266
- readonly fix: "Check the linter (oxlint, biome, or eslint) is installed and its config is valid, then run it manually on the output.";
270
+ readonly code: 'KUBB_LINT_FAILED';
271
+ readonly title: 'Lint failed';
272
+ readonly cause: 'The linter pass over the generated files failed.';
273
+ readonly fix: 'Check the linter (oxlint, biome, or eslint) is installed and its config is valid, then run it manually on the output.';
267
274
  };
268
275
  readonly barrelDuplicateExport: {
269
- readonly code: "KUBB_BARREL_DUPLICATE_EXPORT";
270
- readonly title: "Duplicate barrel export";
271
- readonly cause: "Two generated modules export the same name, so the barrel cannot re-export both.";
272
- readonly fix: "Rename one of the colliding declarations, or configure the plugin resolver to produce distinct names.";
276
+ readonly code: 'KUBB_BARREL_DUPLICATE_EXPORT';
277
+ readonly title: 'Duplicate barrel export';
278
+ readonly cause: 'Two generated modules export the same name, so the barrel cannot re-export both.';
279
+ readonly fix: 'Rename one of the colliding declarations, or configure the plugin resolver to produce distinct names.';
273
280
  };
274
281
  readonly internalError: {
275
- readonly code: "KUBB_INTERNAL_ERROR";
276
- readonly title: "Internal error";
277
- readonly cause: "Kubb hit a state it does not expect. This is a bug in Kubb, not in your config.";
278
- readonly fix: "Rerun with `--reporter json` or `--verbose` to get the stack. Then report it at https://github.com/kubb-labs/kubb/issues with the spec and config that trigger it.";
282
+ readonly code: 'KUBB_INTERNAL_ERROR';
283
+ readonly title: 'Internal error';
284
+ readonly cause: 'Kubb hit a state it does not expect. This is a bug in Kubb, not in your config.';
285
+ readonly fix: 'Rerun with `--reporter json` or `--verbose` to get the stack. Then report it at https://github.com/kubb-labs/kubb/issues with the spec and config that trigger it.';
279
286
  };
280
287
  readonly performance: {
281
- readonly code: "KUBB_PERFORMANCE";
282
- readonly title: "Performance";
283
- readonly cause: "Not a failure. Records a plugin’s elapsed time, summed into the run total.";
284
- readonly fix: "No action. This is an informational metric.";
288
+ readonly code: 'KUBB_PERFORMANCE';
289
+ readonly title: 'Performance';
290
+ readonly cause: 'Not a failure. Records a plugin’s elapsed time, summed into the run total.';
291
+ readonly fix: 'No action. This is an informational metric.';
285
292
  };
286
293
  readonly updateAvailable: {
287
- readonly code: "KUBB_UPDATE_AVAILABLE";
288
- readonly title: "Update available";
289
- readonly cause: "A newer Kubb version is published on npm than the one running.";
290
- readonly fix: "Update the `@kubb/*` packages, for example `npm install -g @kubb/cli`, to get the latest fixes.";
294
+ readonly code: 'KUBB_UPDATE_AVAILABLE';
295
+ readonly title: 'Update available';
296
+ readonly cause: 'A newer Kubb version is published on npm than the one running.';
297
+ readonly fix: 'Update the `@kubb/*` packages, for example `npm install -g @kubb/cli`, to get the latest fixes.';
291
298
  };
292
299
  };
293
300
  /**
294
301
  * Stable codes Kubb attaches to a `Diagnostic`, derived from {@link diagnosticCatalog}. Reference
295
302
  * these instead of inlining the string at a throw site.
296
303
  */
297
- declare const diagnosticCode: { readonly [K in keyof typeof diagnosticCatalog]: (typeof diagnosticCatalog)[K]["code"]; };
304
+ declare const diagnosticCode: { readonly [K in keyof typeof diagnosticCatalog]: (typeof diagnosticCatalog)[K]['code']; };
298
305
  /**
299
306
  * Union of the stable {@link diagnosticCode} values.
300
307
  */
@@ -1826,6 +1833,7 @@ export declare class Diagnostics {
1826
1833
  readonly inputNotFound: "KUBB_INPUT_NOT_FOUND";
1827
1834
  readonly inputRequestFailed: "KUBB_INPUT_REQUEST_FAILED";
1828
1835
  readonly inputUnreachable: "KUBB_INPUT_UNREACHABLE";
1836
+ readonly gitInputFailed: "KUBB_GIT_INPUT_FAILED";
1829
1837
  readonly inputRequired: "KUBB_INPUT_REQUIRED";
1830
1838
  readonly legacyInput: "KUBB_LEGACY_INPUT";
1831
1839
  readonly invalidDocument: "KUBB_INVALID_DOCUMENT";
@@ -3531,22 +3539,48 @@ type ResolverOptions<T extends PluginType> = Omit<T['resolver'], keyof Resolver>
3531
3539
  */
3532
3540
  export declare function createResolver<T extends PluginType>(options: ResolverOptions<T>): T['resolver'];
3533
3541
  //#endregion
3542
+ //#region src/gitInput.d.ts
3543
+ /**
3544
+ * Fetches one commit of a git repository into a temporary directory with a shallow `git fetch`,
3545
+ * so any host and the user's own git credentials work, and relative `$ref` files resolve.
3546
+ * Resolves to the spec path on disk and a `dispose` that deletes the checkout.
3547
+ *
3548
+ * With `publicOnly`, the repository must be an https URL on public addresses, the fetch connects to
3549
+ * the addresses checked, and it does not follow a redirect.
3550
+ */
3551
+ export declare function checkoutGitInput(input: string, signal?: AbortSignal, { publicOnly }?: {
3552
+ publicOnly?: boolean;
3553
+ }): Promise<{
3554
+ path: string;
3555
+ dispose: () => Promise<void>;
3556
+ }>;
3557
+ //#endregion
3558
+ //#region src/publicAddress.d.ts
3559
+ /**
3560
+ * Whether `address` is a routable public IP. Loopback, private, link-local, cloud metadata, and
3561
+ * multicast ranges are not, and an IPv4-mapped IPv6 address counts as the IPv4 address it wraps.
3562
+ * Pass `blocked` to replace the ranges.
3563
+ */
3564
+ export declare function isPublicAddress(address: string, blocked?: net.BlockList): boolean;
3565
+ //#endregion
3534
3566
  //#region src/input.d.ts
3535
3567
  /**
3536
3568
  * What an `input` value points at, once Kubb has looked at it.
3537
3569
  *
3538
3570
  * - `file` is a local file path, absolute or relative to the config file.
3539
3571
  * - `url` is a remote document to fetch.
3572
+ * - `git` is a spec file in a git repository, written as `git+<repo>#<ref>:<path>`.
3540
3573
  * - `inline` is OpenAPI content held in the string itself (JSON or YAML).
3541
3574
  * - `object` is an already-parsed spec.
3542
3575
  */
3543
- type InputKind = 'file' | 'url' | 'inline' | 'object';
3576
+ type InputKind = 'file' | 'url' | 'git' | 'inline' | 'object';
3544
3577
  /**
3545
3578
  * Classifies an `input` value so callers branch on it once instead of repeating the checks.
3546
3579
  *
3547
3580
  * A non-string is a parsed spec (`object`). A string is `inline` when it holds OpenAPI content,
3548
3581
  * meaning it starts with `{` or `[`, spans multiple lines, or opens with a YAML `openapi:` or
3549
- * `swagger:` key. Otherwise a string is a `url` when it parses as one, or a `file` path.
3582
+ * `swagger:` key. Otherwise a string is `git` when it starts with `git+`, a `url` when it parses as
3583
+ * one, or a `file` path.
3550
3584
  */
3551
3585
  export declare function getInputKind(input: NonNullable<Input>): InputKind;
3552
3586
  //#endregion
@@ -3580,7 +3614,7 @@ export declare function resolveCacheDir(root: string): string;
3580
3614
  * await cache.writeItem('output-manifest.json', JSON.stringify(entries))
3581
3615
  * ```
3582
3616
  */
3583
- export declare const cacheStorage: (options?: CacheStorageOptions | undefined) => Storage;
3617
+ export declare const cacheStorage: (options?: CacheStorageOptions | undefined) => import("@kubb/kit").Storage;
3584
3618
  //#endregion
3585
3619
  //#region src/storages/fsStorage.d.ts
3586
3620
  /**
@@ -3609,7 +3643,7 @@ export declare const cacheStorage: (options?: CacheStorageOptions | undefined) =
3609
3643
  * })
3610
3644
  * ```
3611
3645
  */
3612
- export declare const fsStorage: (options?: Record<string, never> | undefined) => Storage;
3646
+ export declare const fsStorage: (options?: Record<string, never> | undefined) => import("@kubb/kit").Storage;
3613
3647
  //#endregion
3614
3648
  //#region src/storages/kubbStorage.d.ts
3615
3649
  type KubbStorageOptions = {
@@ -3658,7 +3692,7 @@ export declare function kubbStorage({ base }?: KubbStorageOptions): import("unst
3658
3692
  * })
3659
3693
  * ```
3660
3694
  */
3661
- export declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
3695
+ export declare const memoryStorage: (options?: Record<string, never> | undefined) => import("@kubb/kit").Storage;
3662
3696
  //#endregion
3663
3697
  //#region src/manifest.d.ts
3664
3698
  /** A value that survives `JSON.stringify` and `JSON.parse` unchanged. */
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { $ as NodeCache, $t as ReporterContext, A as PluginFactory, At as KubbInfoContext, B as ResolveImportsOptions, Bt as RunHookOptions, C as NormalizedPlugin, Ct as KubbGenerationEndContext, D as Override, Dt as KubbHookLineContext, E as OutputOptions, Et as KubbHookEndContext, F as definePlugin, Ft as KubbWarnContext, G as ResolverFile, Gt as createOutputManifest, H as ResolvePathOptions, Ht as KubbDriver, I as BannerMeta, It as PossibleConfig, J as ResolverPatch, Jt as createRenderer, K as ResolverFileParams, Kt as Renderer, L as ResolveBannerContext, Lt as PostGenerateCommand, M as PluginType, Mt as KubbMessageContext, N as ResolvePluginOptions, Nt as KubbPluginsEndContext, O as Plugin, Ot as KubbHookStartContext, P as assertPluginOption, Pt as KubbSuccessContext, Q as defineGenerator, Qt as Reporter, R as ResolveBannerFile, Rt as UserConfig, S as KubbPluginStartContext, St as KubbFilesProcessingUpdateContext, T as OutputMode, Tt as KubbGenerationSummaryContext, U as Resolver, Ut as Hookable, V as ResolveOptionsContext, Vt as runHook, W as ResolverDefault, Wt as OutputManifest, X as Generator, Xt as createStorage, Y as ResolverPathParams, Yt as Storage, Z as GeneratorContext, Zt as GenerationResult, _ as Filter, _t as KubbDiagnosticContext, a as AdapterSource, an as DiagnosticFormatOptions, at as Diagnostics, b as KubbPluginEndContext, bt as KubbFilesProcessingEndContext, c as ExtensionDependency, cn as ParserDefinition, ct as ProblemDiagnostic, d as ExtensionKind, dt as CLIOptions, en as ReporterName, et as Diagnostic, f as ExtensionMeta, ft as Config, g as Exclude, gt as KubbBuildStartContext, h as resolveMeta, ht as KubbBuildEndContext, i as AdapterFactoryOptions, in as logLevel, it as DiagnosticSeverity, j as PluginName, jt as KubbLifecycleStartContext, k as PluginDefinition, kt as KubbHooks, l as ExtensionDependencyRecord, ln as ParserFactory, lt as UpdateDiagnostic, m as defineExtension, mt as Input, n as AdapterDefinition, nn as UserReporter, nt as DiagnosticKind, o as createAdapter, on as SerializedDiagnostic, ot as PerformanceDiagnostic, p as checkCompatibility, pt as FilesContext, q as ResolverFilePathParams, qt as RendererFactory, r as AdapterFactory, rn as createReporter, rt as DiagnosticLocation, s as ExtensionDependencies, sn as Parser, st as ProblemCode, t as Adapter, tn as ReporterPluginFiles, tt as DiagnosticDoc, u as ExtensionFactory, un as defineParser, ut as BuildOutput, v as Group, vt as KubbErrorContext, w as Output, wt as KubbGenerationStartContext, x as KubbPluginSetupContext, xt as KubbFilesProcessingStartContext, y as Include, yt as KubbFileProcessingUpdate, z as ResolveFileOptions, zt as HookResult } from "./createAdapter-DtX_MKL-.js";
1
+ import { $ as NodeCache, $t as ReporterContext, A as PluginFactory, At as KubbInfoContext, B as ResolveImportsOptions, Bt as RunHookOptions, C as NormalizedPlugin, Ct as KubbGenerationEndContext, D as Override, Dt as KubbHookLineContext, E as OutputOptions, Et as KubbHookEndContext, F as definePlugin, Ft as KubbWarnContext, G as ResolverFile, Gt as createOutputManifest, H as ResolvePathOptions, Ht as KubbDriver, I as BannerMeta, It as PossibleConfig, J as ResolverPatch, Jt as createRenderer, K as ResolverFileParams, Kt as Renderer, L as ResolveBannerContext, Lt as PostGenerateCommand, M as PluginType, Mt as KubbMessageContext, N as ResolvePluginOptions, Nt as KubbPluginsEndContext, O as Plugin, Ot as KubbHookStartContext, P as assertPluginOption, Pt as KubbSuccessContext, Q as defineGenerator, Qt as Reporter, R as ResolveBannerFile, Rt as UserConfig, S as KubbPluginStartContext, St as KubbFilesProcessingUpdateContext, T as OutputMode, Tt as KubbGenerationSummaryContext, U as Resolver, Ut as Hookable, V as ResolveOptionsContext, Vt as runHook, W as ResolverDefault, Wt as OutputManifest, X as Generator, Xt as createStorage, Y as ResolverPathParams, Yt as Storage, Z as GeneratorContext, Zt as GenerationResult, _ as Filter, _t as KubbDiagnosticContext, a as AdapterSource, an as DiagnosticFormatOptions, at as Diagnostics, b as KubbPluginEndContext, bt as KubbFilesProcessingEndContext, c as ExtensionDependency, cn as ParserDefinition, ct as ProblemDiagnostic, d as ExtensionKind, dt as CLIOptions, en as ReporterName, et as Diagnostic, f as ExtensionMeta, ft as Config, g as Exclude, gt as KubbBuildStartContext, h as resolveMeta, ht as KubbBuildEndContext, i as AdapterFactoryOptions, in as logLevel, it as DiagnosticSeverity, j as PluginName, jt as KubbLifecycleStartContext, k as PluginDefinition, kt as KubbHooks, l as ExtensionDependencyRecord, ln as ParserFactory, lt as UpdateDiagnostic, m as defineExtension, mt as Input, n as AdapterDefinition, nn as UserReporter, nt as DiagnosticKind, o as createAdapter, on as SerializedDiagnostic, ot as PerformanceDiagnostic, p as checkCompatibility, pt as FilesContext, q as ResolverFilePathParams, qt as RendererFactory, r as AdapterFactory, rn as createReporter, rt as DiagnosticLocation, s as ExtensionDependencies, sn as Parser, st as ProblemCode, t as Adapter, tn as ReporterPluginFiles, tt as DiagnosticDoc, u as ExtensionFactory, un as defineParser, ut as BuildOutput, v as Group, vt as KubbErrorContext, w as Output, wt as KubbGenerationStartContext, x as KubbPluginSetupContext, xt as KubbFilesProcessingStartContext, y as Include, yt as KubbFileProcessingUpdate, z as ResolveFileOptions, zt as HookResult } from "./createAdapter-DFXvZLZC.js";
2
2
  import { FileNode, Macro, UserFileNode } from "@kubb/ast";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
+ import net from "node:net";
4
5
  //#region src/composables.d.ts
5
6
  /**
6
7
  * Holds the setup context of the plugin whose `setup` or `kubb:plugin:setup` is running. `KubbDriver` sets it for each plugin.
@@ -316,22 +317,48 @@ type ResolverOptions<T extends PluginType> = Omit<T['resolver'], keyof Resolver>
316
317
  */
317
318
  export declare function createResolver<T extends PluginType>(options: ResolverOptions<T>): T['resolver'];
318
319
  //#endregion
320
+ //#region src/gitInput.d.ts
321
+ /**
322
+ * Fetches one commit of a git repository into a temporary directory with a shallow `git fetch`,
323
+ * so any host and the user's own git credentials work, and relative `$ref` files resolve.
324
+ * Resolves to the spec path on disk and a `dispose` that deletes the checkout.
325
+ *
326
+ * With `publicOnly`, the repository must be an https URL on public addresses, the fetch connects to
327
+ * the addresses checked, and it does not follow a redirect.
328
+ */
329
+ export declare function checkoutGitInput(input: string, signal?: AbortSignal, { publicOnly }?: {
330
+ publicOnly?: boolean;
331
+ }): Promise<{
332
+ path: string;
333
+ dispose: () => Promise<void>;
334
+ }>;
335
+ //#endregion
336
+ //#region src/publicAddress.d.ts
337
+ /**
338
+ * Whether `address` is a routable public IP. Loopback, private, link-local, cloud metadata, and
339
+ * multicast ranges are not, and an IPv4-mapped IPv6 address counts as the IPv4 address it wraps.
340
+ * Pass `blocked` to replace the ranges.
341
+ */
342
+ export declare function isPublicAddress(address: string, blocked?: net.BlockList): boolean;
343
+ //#endregion
319
344
  //#region src/input.d.ts
320
345
  /**
321
346
  * What an `input` value points at, once Kubb has looked at it.
322
347
  *
323
348
  * - `file` is a local file path, absolute or relative to the config file.
324
349
  * - `url` is a remote document to fetch.
350
+ * - `git` is a spec file in a git repository, written as `git+<repo>#<ref>:<path>`.
325
351
  * - `inline` is OpenAPI content held in the string itself (JSON or YAML).
326
352
  * - `object` is an already-parsed spec.
327
353
  */
328
- type InputKind = 'file' | 'url' | 'inline' | 'object';
354
+ type InputKind = 'file' | 'url' | 'git' | 'inline' | 'object';
329
355
  /**
330
356
  * Classifies an `input` value so callers branch on it once instead of repeating the checks.
331
357
  *
332
358
  * A non-string is a parsed spec (`object`). A string is `inline` when it holds OpenAPI content,
333
359
  * meaning it starts with `{` or `[`, spans multiple lines, or opens with a YAML `openapi:` or
334
- * `swagger:` key. Otherwise a string is a `url` when it parses as one, or a `file` path.
360
+ * `swagger:` key. Otherwise a string is `git` when it starts with `git+`, a `url` when it parses as
361
+ * one, or a `file` path.
335
362
  */
336
363
  export declare function getInputKind(input: NonNullable<Input>): InputKind;
337
364
  //#endregion
@@ -365,7 +392,7 @@ export declare function resolveCacheDir(root: string): string;
365
392
  * await cache.writeItem('output-manifest.json', JSON.stringify(entries))
366
393
  * ```
367
394
  */
368
- export declare const cacheStorage: (options?: CacheStorageOptions | undefined) => Storage;
395
+ export declare const cacheStorage: (options?: CacheStorageOptions | undefined) => import("@kubb/kit").Storage;
369
396
  //#endregion
370
397
  //#region src/storages/fsStorage.d.ts
371
398
  /**
@@ -394,7 +421,7 @@ export declare const cacheStorage: (options?: CacheStorageOptions | undefined) =
394
421
  * })
395
422
  * ```
396
423
  */
397
- export declare const fsStorage: (options?: Record<string, never> | undefined) => Storage;
424
+ export declare const fsStorage: (options?: Record<string, never> | undefined) => import("@kubb/kit").Storage;
398
425
  //#endregion
399
426
  //#region src/storages/kubbStorage.d.ts
400
427
  type KubbStorageOptions = {
@@ -443,7 +470,7 @@ export declare function kubbStorage({ base }?: KubbStorageOptions): import("unst
443
470
  * })
444
471
  * ```
445
472
  */
446
- export declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
473
+ export declare const memoryStorage: (options?: Record<string, never> | undefined) => import("@kubb/kit").Storage;
447
474
  //#endregion
448
475
  //#region src/manifest.d.ts
449
476
  /** A value that survives `JSON.stringify` and `JSON.parse` unchanged. */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as inParallel, C as useOptions, D as Diagnostics, E as resolveMeta, F as rm, I as write, L as writeRaw, M as isPathInside, N as listFiles, O as formatMs, P as read, R as toError, S as useKubb, T as defineExtension, _ as setMacros, b as tryUseKubb, c as Resolver, d as definePlugin, f as addGenerator, g as requirePlugin, h as kubbContext, j as existsSync$1, k as getElapsedMs, l as getInputKind, m as injectFile, n as KubbDriver, o as _usingCtx, p as addMacro, s as createResolver, t as Hookable, u as assertPluginOption, v as setOptions, w as checkCompatibility, x as useConfig, y as setResolver } from "./Hookable-CvStaYYq.js";
1
+ import { A as formatMs, B as toError, C as useConfig, D as defineExtension, E as checkCompatibility, F as listFiles, I as read, L as rm$1, M as inParallel, N as existsSync$1, O as resolveMeta, P as isPathInside, R as write, S as tryUseKubb, T as useOptions, _ as kubbContext, b as setOptions, c as Resolver, d as isPublicAddress, f as assertPluginOption, g as injectFile, h as addMacro, j as getElapsedMs, k as Diagnostics, l as getInputKind, m as addGenerator, n as KubbDriver, o as _usingCtx, p as definePlugin, s as createResolver, t as Hookable, u as checkoutGitInput, v as requirePlugin, w as useKubb, x as setResolver, y as setMacros, z as writeRaw } from "./Hookable-D3jKB944.js";
2
2
  import { createRequire } from "node:module";
3
3
  import { isValid } from "verkit";
4
4
  import process$1 from "node:process";
@@ -7,8 +7,8 @@ import { readFile } from "node:fs/promises";
7
7
  import path, { isAbsolute, join, relative, resolve } from "node:path";
8
8
  import { chmodSync, existsSync, mkdirSync } from "node:fs";
9
9
  import { stripVTControlCharacters, styleText } from "node:util";
10
- import { hash, randomUUID } from "node:crypto";
11
10
  import { homedir, tmpdir } from "node:os";
11
+ import { hash, randomUUID } from "node:crypto";
12
12
  import { createInterface } from "node:readline";
13
13
  import { createStorage as createStorage$1 } from "unstorage";
14
14
  import fsDriver from "unstorage/drivers/fs";
@@ -313,7 +313,7 @@ const fsStorage = createStorage(() => ({
313
313
  });
314
314
  },
315
315
  async removeItem(key) {
316
- await rm(resolve(key), { force: true });
316
+ await rm$1(resolve(key), { force: true });
317
317
  },
318
318
  async readKeys(base) {
319
319
  const resolvedBase = resolve(base ?? process.cwd());
@@ -325,7 +325,7 @@ const fsStorage = createStorage(() => ({
325
325
  },
326
326
  async empty(base) {
327
327
  if (!base) return;
328
- await rm(resolve(base), {
328
+ await rm$1(resolve(base), {
329
329
  recursive: true,
330
330
  force: true
331
331
  });
@@ -1384,6 +1384,6 @@ async function readInstalledPackages({ root, packages = [], resolveFrom = [] })
1384
1384
  }));
1385
1385
  }
1386
1386
  //#endregion
1387
- export { Diagnostics, Hookable, KubbDriver, Resolver, addGenerator, addMacro, assertPluginOption, cacheStorage, checkCompatibility, cliReporter, createAdapter, createCliReporter, createKubb, createOutputManifest, createRenderer, createReporter, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, htmlReporter, injectFile, isExtensionManifest, isPackageName, isRegistryEntry, jsonReporter, kubbContext, kubbStorage, logLevel, manifestProblems, memoryStorage, readInstalledPackages, requirePlugin, resolveCacheDir, resolveKubbDir, resolveMeta, runHook, runOutputPasses, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions };
1387
+ export { Diagnostics, Hookable, KubbDriver, Resolver, addGenerator, addMacro, assertPluginOption, cacheStorage, checkCompatibility, checkoutGitInput, cliReporter, createAdapter, createCliReporter, createKubb, createOutputManifest, createRenderer, createReporter, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, htmlReporter, injectFile, isExtensionManifest, isPackageName, isPublicAddress, isRegistryEntry, jsonReporter, kubbContext, kubbStorage, logLevel, manifestProblems, memoryStorage, readInstalledPackages, requirePlugin, resolveCacheDir, resolveKubbDir, resolveMeta, runHook, runOutputPasses, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions };
1388
1388
 
1389
1389
  //# sourceMappingURL=index.js.map