@kubb/agent 5.0.0-alpha.34 → 5.0.0-alpha.36
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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +1790 -20812
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +16 -14
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +16 -14
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/constants.js +18 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/permessage-deflate.js +514 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/sender.js +602 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/stream.js +159 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket-server.js +540 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket.js +1388 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/package.json +69 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/wrapper.mjs +8 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/buffer-util.js +131 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/event-target.js +292 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/extension.js +203 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/limiter.js +55 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/receiver.js +706 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/subprotocol.js +62 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/validation.js +152 -0
- package/.output/server/node_modules/@clack/core/dist/index.mjs +11 -0
- package/.output/server/node_modules/@clack/core/package.json +60 -0
- package/.output/server/node_modules/@clack/prompts/dist/index.mjs +137 -0
- package/.output/server/node_modules/@clack/prompts/package.json +65 -0
- package/.output/server/node_modules/@kubb/ast/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/ast/dist/index.js +423 -0
- package/.output/server/node_modules/@kubb/ast/package.json +70 -0
- package/.output/server/node_modules/@kubb/core/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/core/dist/hooks.js +23 -0
- package/.output/server/node_modules/@kubb/core/dist/index.js +2311 -0
- package/.output/server/node_modules/@kubb/core/package.json +109 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/chunk-O_arW02_.js +17 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/defaultParser-iCpMSYCp.js +15 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/getRelativePath-NAm_Y-vp.js +55 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +653 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/onProcessExit-Cput7j2c.js +742 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +101 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +17 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +375 -0
- package/.output/server/node_modules/@kubb/fabric-core/package.json +111 -0
- package/.output/server/node_modules/@kubb/oas/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/oas/dist/index.js +918 -0
- package/.output/server/node_modules/@kubb/oas/package.json +94 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/StaticClassClient-bCe7RG_w.js +636 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/components.js +2 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/generators-BffddRNu.js +723 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/index.js +124 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/axios.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/fetch.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/templates/config.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-client/package.json +153 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/components-BK_6GU4v.js +257 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/generators-D5YFtyyC.js +71 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/index.js +79 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/package.json +108 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/components-BkBIov4R.js +419 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/fakerGenerator-BztogaeO.js +200 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/index.js +141 -0
- package/.output/server/node_modules/@kubb/plugin-faker/package.json +103 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/Server-H3SwqhwF.js +178 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/generators-BqkMrcs9.js +274 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/index.js +122 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/package.json +107 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/components-DgtTZkWX.js +277 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/generators-C34kqa1L.js +161 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/index.js +84 -0
- package/.output/server/node_modules/@kubb/plugin-msw/package.json +109 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/SchemaMapper-CqMkO2T1.js +58 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/generators-D7C3CXsN.js +79 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/generators.js +2 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/getFooter-Pw3tLCiV.js +112 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/hooks.js +200 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/index.js +408 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/requestBody-pRavthCw.js +1336 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/utils.js +268 -0
- package/.output/server/node_modules/@kubb/plugin-oas/package.json +122 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/components-CpyHYGOw.js +1520 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/generators-CpiBv5eE.js +1427 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/index.js +166 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/package.json +112 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/dist/index.js +65 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/package.json +85 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/static/redoc.hbs +22 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/components-BhStIi1M.js +665 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/generators-CQClzsST.js +415 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/index.js +145 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/package.json +113 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/components-DntKBsnB.js +666 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/generators-BtTsGGrM.js +414 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/index.js +145 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/package.json +113 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/components-DRDGvgXG.js +702 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/generators-ClWZJ-YG.js +399 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/index.js +144 -0
- package/.output/server/node_modules/@kubb/plugin-swr/package.json +115 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/components-C7fu-sK1.js +723 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/index.js +2 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/plugin-CYC-FGXe.js +479 -0
- package/.output/server/node_modules/@kubb/plugin-ts/package.json +105 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/components-_AMBl0g-.js +1029 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/generators-Zb1s5Wmb.js +661 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/index.js +157 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/package.json +114 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/components-eECfXVou.js +842 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/generators-D1R6NNf2.js +290 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/index.js +175 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/templates/ToZod.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-zod/package.json +112 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/chunk-BGCRLu6H.js +38 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +525 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime-Bl0DfUmV.js +1448 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +12 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/parsers.js +2 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +4 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/reactPlugin-QQPrjNuQ.js +17813 -0
- package/.output/server/node_modules/@kubb/react-fabric/package.json +143 -0
- package/.output/server/node_modules/@redocly/config/lib/root-config-schema.js +11 -1
- package/.output/server/node_modules/@redocly/config/package.json +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-document.js +25 -10
- package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-visitor.js +32 -29
- package/.output/server/node_modules/@redocly/openapi-core/lib/config/config.js +5 -0
- package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas2/index.js +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas2/remove-unused-components.js +47 -38
- package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas3/index.js +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas3/remove-unused-components.js +45 -41
- package/.output/server/node_modules/@redocly/openapi-core/lib/rules/common/no-http-verbs-in-paths.js +3 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/rules/common/no-required-schema-properties-undefined.js +41 -55
- package/.output/server/node_modules/@redocly/openapi-core/lib/walk.js +28 -16
- package/.output/server/node_modules/@redocly/openapi-core/package.json +2 -2
- package/.output/server/node_modules/buffer-from/index.js +72 -0
- package/.output/server/node_modules/buffer-from/package.json +19 -0
- package/.output/server/node_modules/fast-string-truncated-width/dist/index.js +171 -0
- package/.output/server/node_modules/fast-string-truncated-width/dist/utils.js +15 -0
- package/.output/server/node_modules/fast-string-truncated-width/package.json +35 -0
- package/.output/server/node_modules/fast-string-width/dist/index.js +14 -0
- package/.output/server/node_modules/fast-string-width/package.json +34 -0
- package/.output/server/node_modules/fast-wrap-ansi/lib/main.js +216 -0
- package/.output/server/node_modules/fast-wrap-ansi/package.json +51 -0
- package/.output/server/node_modules/p-limit/index.js +127 -0
- package/.output/server/node_modules/p-limit/package.json +58 -0
- package/.output/server/node_modules/react-devtools-core/dist/backend.js +18302 -0
- package/.output/server/node_modules/react-devtools-core/package.json +38 -0
- package/.output/server/node_modules/sisteransi/package.json +34 -0
- package/.output/server/node_modules/sisteransi/src/index.js +58 -0
- package/.output/server/node_modules/source-map-support/package.json +31 -0
- package/.output/server/node_modules/source-map-support/source-map-support.js +625 -0
- package/.output/server/node_modules/typescript/lib/typescript.js +200276 -0
- package/.output/server/node_modules/typescript/package.json +120 -0
- package/.output/server/node_modules/yocto-queue/index.js +90 -0
- package/.output/server/node_modules/yocto-queue/package.json +48 -0
- package/.output/server/package.json +35 -4
- package/package.json +20 -20
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/buffer-util.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/event-target.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/extension.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/limiter.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/receiver.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/subprotocol.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/validation.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/constants.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/permessage-deflate.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/sender.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/stream.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket-server.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/package.json +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/wrapper.mjs +0 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import { n as getBanner, r as camelCase, t as getFooter } from "./getFooter-Pw3tLCiV.js";
|
|
3
|
+
import { n as withRequiredRequestBodySchema, r as SchemaGenerator, s as getSchemaFactory, t as isRequestBodyRequired } from "./requestBody-pRavthCw.js";
|
|
4
|
+
import { n as schemaKeywords } from "./SchemaMapper-CqMkO2T1.js";
|
|
5
|
+
import { isOptional } from "@kubb/oas";
|
|
6
|
+
//#region ../../internals/utils/src/reserved.ts
|
|
7
|
+
/**
|
|
8
|
+
* Returns `true` when `name` is a syntactically valid JavaScript variable name.
|
|
9
|
+
*/
|
|
10
|
+
function isValidVarName(name) {
|
|
11
|
+
try {
|
|
12
|
+
new Function(`var ${name}`);
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region ../../internals/utils/src/urlPath.ts
|
|
20
|
+
/**
|
|
21
|
+
* Parses and transforms an OpenAPI/Swagger path string into various URL formats.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const p = new URLPath('/pet/{petId}')
|
|
25
|
+
* p.URL // '/pet/:petId'
|
|
26
|
+
* p.template // '`/pet/${petId}`'
|
|
27
|
+
*/
|
|
28
|
+
var URLPath = class {
|
|
29
|
+
/** The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`. */
|
|
30
|
+
path;
|
|
31
|
+
#options;
|
|
32
|
+
constructor(path, options = {}) {
|
|
33
|
+
this.path = path;
|
|
34
|
+
this.#options = options;
|
|
35
|
+
}
|
|
36
|
+
/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */
|
|
37
|
+
get URL() {
|
|
38
|
+
return this.toURLPath();
|
|
39
|
+
}
|
|
40
|
+
/** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`). */
|
|
41
|
+
get isURL() {
|
|
42
|
+
try {
|
|
43
|
+
return !!new URL(this.path).href;
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
|
|
53
|
+
* new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
|
|
54
|
+
*/
|
|
55
|
+
get template() {
|
|
56
|
+
return this.toTemplateString();
|
|
57
|
+
}
|
|
58
|
+
/** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set. */
|
|
59
|
+
get object() {
|
|
60
|
+
return this.toObject();
|
|
61
|
+
}
|
|
62
|
+
/** Returns a map of path parameter names, or `undefined` when the path has no parameters. */
|
|
63
|
+
get params() {
|
|
64
|
+
return this.getParams();
|
|
65
|
+
}
|
|
66
|
+
#transformParam(raw) {
|
|
67
|
+
const param = isValidVarName(raw) ? raw : camelCase(raw);
|
|
68
|
+
return this.#options.casing === "camelcase" ? camelCase(param) : param;
|
|
69
|
+
}
|
|
70
|
+
/** Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name. */
|
|
71
|
+
#eachParam(fn) {
|
|
72
|
+
for (const match of this.path.matchAll(/\{([^}]+)\}/g)) {
|
|
73
|
+
const raw = match[1];
|
|
74
|
+
fn(raw, this.#transformParam(raw));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
toObject({ type = "path", replacer, stringify } = {}) {
|
|
78
|
+
const object = {
|
|
79
|
+
url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
|
|
80
|
+
params: this.getParams()
|
|
81
|
+
};
|
|
82
|
+
if (stringify) {
|
|
83
|
+
if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
84
|
+
if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
|
|
85
|
+
return `{ url: '${object.url}' }`;
|
|
86
|
+
}
|
|
87
|
+
return object;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
91
|
+
* An optional `replacer` can transform each extracted parameter name before interpolation.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
|
|
95
|
+
*/
|
|
96
|
+
toTemplateString({ prefix = "", replacer } = {}) {
|
|
97
|
+
return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => {
|
|
98
|
+
if (i % 2 === 0) return part;
|
|
99
|
+
const param = this.#transformParam(part);
|
|
100
|
+
return `\${${replacer ? replacer(param) : param}}`;
|
|
101
|
+
}).join("")}\``;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Extracts all `{param}` segments from the path and returns them as a key-value map.
|
|
105
|
+
* An optional `replacer` transforms each parameter name in both key and value positions.
|
|
106
|
+
* Returns `undefined` when no path parameters are found.
|
|
107
|
+
*/
|
|
108
|
+
getParams(replacer) {
|
|
109
|
+
const params = {};
|
|
110
|
+
this.#eachParam((_raw, param) => {
|
|
111
|
+
const key = replacer ? replacer(param) : param;
|
|
112
|
+
params[key] = key;
|
|
113
|
+
});
|
|
114
|
+
return Object.keys(params).length > 0 ? params : void 0;
|
|
115
|
+
}
|
|
116
|
+
/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */
|
|
117
|
+
toURLPath() {
|
|
118
|
+
return this.path.replace(/\{([^}]+)\}/g, ":$1");
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/utils/getComments.ts
|
|
123
|
+
function getComments(operation) {
|
|
124
|
+
return [
|
|
125
|
+
operation.getDescription() && `@description ${operation.getDescription()}`,
|
|
126
|
+
operation.getSummary() && `@summary ${operation.getSummary()}`,
|
|
127
|
+
operation.path && `{@link ${new URLPath(operation.path).URL}}`,
|
|
128
|
+
operation.isDeprecated() && "@deprecated"
|
|
129
|
+
].filter((x) => Boolean(x)).flatMap((text) => {
|
|
130
|
+
return text.split(/\r?\n/).map((line) => line.trim());
|
|
131
|
+
}).filter((x) => Boolean(x));
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/utils/getImports.ts
|
|
135
|
+
/**
|
|
136
|
+
* Get imports from a schema tree by extracting all ref schemas that are importable
|
|
137
|
+
*/
|
|
138
|
+
function getImports(tree) {
|
|
139
|
+
const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref);
|
|
140
|
+
if (!refs) return [];
|
|
141
|
+
return refs.map((item) => {
|
|
142
|
+
if (!item.args.path || !item.args.isImportable) return;
|
|
143
|
+
return {
|
|
144
|
+
name: [item.args.name],
|
|
145
|
+
path: item.args.path
|
|
146
|
+
};
|
|
147
|
+
}).filter((x) => x !== void 0);
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/utils/getParams.ts
|
|
151
|
+
/**
|
|
152
|
+
*
|
|
153
|
+
* @deprecated
|
|
154
|
+
* TODO move to operationManager hook
|
|
155
|
+
*/
|
|
156
|
+
function getASTParams(operationSchema, { typed = false, casing, override } = {}) {
|
|
157
|
+
if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) return [];
|
|
158
|
+
const requiredFields = Array.isArray(operationSchema.schema.required) ? operationSchema.schema.required : [];
|
|
159
|
+
return Object.entries(operationSchema.schema.properties).map(([name]) => {
|
|
160
|
+
const accessName = casing === "camelcase" ? camelCase(name) : name;
|
|
161
|
+
const data = {
|
|
162
|
+
name,
|
|
163
|
+
enabled: !!name,
|
|
164
|
+
required: requiredFields.includes(name),
|
|
165
|
+
type: typed ? `${operationSchema.name}["${accessName}"]` : void 0
|
|
166
|
+
};
|
|
167
|
+
return override ? override(data) : data;
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function getPathParams(operationSchema, options = {}) {
|
|
171
|
+
return getASTParams(operationSchema, options).reduce((acc, curr) => {
|
|
172
|
+
if (curr.name && curr.enabled) {
|
|
173
|
+
let name = curr.name;
|
|
174
|
+
if (options.casing === "camelcase") name = camelCase(name);
|
|
175
|
+
else if (!isValidVarName(name)) name = camelCase(name);
|
|
176
|
+
acc[name] = {
|
|
177
|
+
default: curr.default,
|
|
178
|
+
type: curr.type,
|
|
179
|
+
optional: !curr.required
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return acc;
|
|
183
|
+
}, {});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get a mapping of camelCase parameter names to their original names
|
|
187
|
+
* Used for mapping function parameters to backend parameter names
|
|
188
|
+
*/
|
|
189
|
+
function getParamsMapping(operationSchema, options = {}) {
|
|
190
|
+
if (!operationSchema || !operationSchema.schema.properties) return;
|
|
191
|
+
const allEntries = [];
|
|
192
|
+
let hasTransformation = false;
|
|
193
|
+
Object.entries(operationSchema.schema.properties).forEach(([originalName]) => {
|
|
194
|
+
let transformedName = originalName;
|
|
195
|
+
if (options.casing === "camelcase") transformedName = camelCase(originalName);
|
|
196
|
+
else if (!isValidVarName(originalName)) transformedName = camelCase(originalName);
|
|
197
|
+
allEntries.push([originalName, transformedName]);
|
|
198
|
+
if (transformedName !== originalName) hasTransformation = true;
|
|
199
|
+
});
|
|
200
|
+
if (options.casing === "camelcase" && hasTransformation) return Object.fromEntries(allEntries);
|
|
201
|
+
const mapping = {};
|
|
202
|
+
allEntries.forEach(([originalName, transformedName]) => {
|
|
203
|
+
if (transformedName !== originalName) mapping[originalName] = transformedName;
|
|
204
|
+
});
|
|
205
|
+
return Object.keys(mapping).length > 0 ? mapping : void 0;
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/utils/getSchemas.ts
|
|
209
|
+
/**
|
|
210
|
+
* Collect schemas from OpenAPI components (schemas, responses, requestBodies)
|
|
211
|
+
* and return them in dependency order along with name mapping for collision resolution.
|
|
212
|
+
*
|
|
213
|
+
* This function is a wrapper around the oas.getSchemas() method for backward compatibility.
|
|
214
|
+
* New code should use oas.getSchemas() directly.
|
|
215
|
+
*
|
|
216
|
+
* @deprecated Use oas.getSchemas() instead
|
|
217
|
+
*/
|
|
218
|
+
function getSchemas({ oas, contentType, includes = [
|
|
219
|
+
"schemas",
|
|
220
|
+
"requestBodies",
|
|
221
|
+
"responses"
|
|
222
|
+
], collisionDetection }) {
|
|
223
|
+
return oas.getSchemas({
|
|
224
|
+
contentType,
|
|
225
|
+
includes,
|
|
226
|
+
collisionDetection
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/utils/paramsCasing.ts
|
|
231
|
+
/**
|
|
232
|
+
* Apply casing transformation to schema properties
|
|
233
|
+
* Only transforms property names, not nested schemas
|
|
234
|
+
*/
|
|
235
|
+
function applyParamsCasing(schema, casing) {
|
|
236
|
+
if (!casing || !schema.properties) return schema;
|
|
237
|
+
const transformedProperties = {};
|
|
238
|
+
const transformedRequired = [];
|
|
239
|
+
Object.entries(schema.properties).forEach(([originalName, propertySchema]) => {
|
|
240
|
+
let transformedName = originalName;
|
|
241
|
+
if (casing === "camelcase") transformedName = camelCase(originalName);
|
|
242
|
+
else if (!isValidVarName(originalName)) transformedName = camelCase(originalName);
|
|
243
|
+
transformedProperties[transformedName] = propertySchema;
|
|
244
|
+
});
|
|
245
|
+
if (Array.isArray(schema.required)) schema.required.forEach((originalName) => {
|
|
246
|
+
let transformedName = originalName;
|
|
247
|
+
if (casing === "camelcase") transformedName = camelCase(originalName);
|
|
248
|
+
else if (!isValidVarName(originalName)) transformedName = camelCase(originalName);
|
|
249
|
+
transformedRequired.push(transformedName);
|
|
250
|
+
});
|
|
251
|
+
return {
|
|
252
|
+
...schema,
|
|
253
|
+
properties: transformedProperties,
|
|
254
|
+
...transformedRequired.length > 0 && { required: transformedRequired }
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Check if this schema is a parameter schema (pathParams, queryParams, or headerParams)
|
|
259
|
+
* Only these should be transformed, not response/data/body
|
|
260
|
+
*/
|
|
261
|
+
function isParameterSchema(schemaName) {
|
|
262
|
+
const lowerName = schemaName.toLowerCase();
|
|
263
|
+
return lowerName.includes("pathparams") || lowerName.includes("queryparams") || lowerName.includes("headerparams");
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
export { applyParamsCasing, getBanner, getComments, getFooter, getImports, getParamsMapping, getPathParams, getSchemaFactory, getSchemas, isOptional, isParameterSchema, isRequestBodyRequired, withRequiredRequestBodySchema };
|
|
267
|
+
|
|
268
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kubb/plugin-oas",
|
|
3
|
+
"version": "4.37.2",
|
|
4
|
+
"description": "OpenAPI Specification (OAS) plugin for Kubb, providing core functionality for parsing and processing OpenAPI/Swagger schemas for code generation.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"openapi",
|
|
7
|
+
"swagger",
|
|
8
|
+
"oas",
|
|
9
|
+
"openapi-v3",
|
|
10
|
+
"api-specification",
|
|
11
|
+
"schema-processing",
|
|
12
|
+
"schema-parser",
|
|
13
|
+
"rest-api",
|
|
14
|
+
"typescript",
|
|
15
|
+
"code-generator",
|
|
16
|
+
"codegen",
|
|
17
|
+
"plugins",
|
|
18
|
+
"kubb"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/kubb-labs/kubb.git",
|
|
23
|
+
"directory": "packages/plugin-oas"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"author": "stijnvanhulle",
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"require": "./dist/index.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./generators": {
|
|
35
|
+
"import": "./dist/generators.js",
|
|
36
|
+
"require": "./dist/generators.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./hooks": {
|
|
39
|
+
"import": "./dist/hooks.js",
|
|
40
|
+
"require": "./dist/hooks.cjs"
|
|
41
|
+
},
|
|
42
|
+
"./mocks": {
|
|
43
|
+
"import": "./dist/mocks.js",
|
|
44
|
+
"require": "./dist/mocks.cjs"
|
|
45
|
+
},
|
|
46
|
+
"./utils": {
|
|
47
|
+
"import": "./dist/utils.js",
|
|
48
|
+
"require": "./dist/utils.cjs"
|
|
49
|
+
},
|
|
50
|
+
"./package.json": "./package.json"
|
|
51
|
+
},
|
|
52
|
+
"types": "./dist/index.d.ts",
|
|
53
|
+
"typesVersions": {
|
|
54
|
+
"*": {
|
|
55
|
+
"utils": [
|
|
56
|
+
"./dist/utils.d.ts"
|
|
57
|
+
],
|
|
58
|
+
"hooks": [
|
|
59
|
+
"./dist/hooks.d.ts"
|
|
60
|
+
],
|
|
61
|
+
"mocks": [
|
|
62
|
+
"./dist/mocks.d.ts"
|
|
63
|
+
],
|
|
64
|
+
"generators": [
|
|
65
|
+
"./dist/generators.d.ts"
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"files": [
|
|
70
|
+
"src",
|
|
71
|
+
"dist",
|
|
72
|
+
"!/**/**.test.**",
|
|
73
|
+
"!/**/__tests__/**",
|
|
74
|
+
"!/**/__snapshots__/**"
|
|
75
|
+
],
|
|
76
|
+
"size-limit": [
|
|
77
|
+
{
|
|
78
|
+
"path": "./dist/*.js",
|
|
79
|
+
"limit": "510 KiB",
|
|
80
|
+
"gzip": true
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
"dependencies": {
|
|
84
|
+
"@kubb/fabric-core": "0.14.0",
|
|
85
|
+
"@kubb/react-fabric": "0.14.0",
|
|
86
|
+
"remeda": "^2.33.6",
|
|
87
|
+
"@kubb/core": "4.37.2",
|
|
88
|
+
"@kubb/oas": "4.37.2"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"@kubb/fabric-core": "0.14.0",
|
|
92
|
+
"@kubb/react-fabric": "0.14.0"
|
|
93
|
+
},
|
|
94
|
+
"engines": {
|
|
95
|
+
"node": ">=20"
|
|
96
|
+
},
|
|
97
|
+
"publishConfig": {
|
|
98
|
+
"access": "public",
|
|
99
|
+
"registry": "https://registry.npmjs.org/"
|
|
100
|
+
},
|
|
101
|
+
"devDependencies": {
|
|
102
|
+
"p-limit": "^7.3.0",
|
|
103
|
+
"@internals/utils": "0.0.0"
|
|
104
|
+
},
|
|
105
|
+
"main": "./dist/index.cjs",
|
|
106
|
+
"module": "./dist/index.js",
|
|
107
|
+
"inlinedDependencies": {
|
|
108
|
+
"p-limit": "7.3.0",
|
|
109
|
+
"yocto-queue": "1.2.2"
|
|
110
|
+
},
|
|
111
|
+
"scripts": {
|
|
112
|
+
"build": "tsdown && size-limit",
|
|
113
|
+
"clean": "npx rimraf ./dist",
|
|
114
|
+
"lint": "bun biome lint .",
|
|
115
|
+
"lint:fix": "bun biome lint --fix --unsafe .",
|
|
116
|
+
"release": "pnpm publish --no-git-check",
|
|
117
|
+
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
118
|
+
"start": "tsdown --watch",
|
|
119
|
+
"test": "vitest --passWithNoTests",
|
|
120
|
+
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
|
121
|
+
}
|
|
122
|
+
}
|