@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,79 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import { n as getBanner, r as camelCase, t as getFooter } from "./getFooter-Pw3tLCiV.js";
|
|
3
|
+
//#region src/generators/createGenerator.ts
|
|
4
|
+
function createGenerator(generator) {
|
|
5
|
+
return {
|
|
6
|
+
type: "core",
|
|
7
|
+
version: generator.version ?? "1",
|
|
8
|
+
async operations() {
|
|
9
|
+
return [];
|
|
10
|
+
},
|
|
11
|
+
async operation() {
|
|
12
|
+
return [];
|
|
13
|
+
},
|
|
14
|
+
async schema() {
|
|
15
|
+
return [];
|
|
16
|
+
},
|
|
17
|
+
...generator
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/generators/createReactGenerator.ts
|
|
22
|
+
/****
|
|
23
|
+
* Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
|
|
24
|
+
*
|
|
25
|
+
* The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.
|
|
26
|
+
*
|
|
27
|
+
* @returns A generator object with async methods for operations, operation, and schema file generation.
|
|
28
|
+
*/
|
|
29
|
+
function createReactGenerator(generator) {
|
|
30
|
+
return {
|
|
31
|
+
type: "react",
|
|
32
|
+
version: generator.version ?? "1",
|
|
33
|
+
Operations() {
|
|
34
|
+
return null;
|
|
35
|
+
},
|
|
36
|
+
Operation() {
|
|
37
|
+
return null;
|
|
38
|
+
},
|
|
39
|
+
Schema() {
|
|
40
|
+
return null;
|
|
41
|
+
},
|
|
42
|
+
...generator
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/generators/jsonGenerator.ts
|
|
47
|
+
const jsonGenerator = createGenerator({
|
|
48
|
+
name: "plugin-oas",
|
|
49
|
+
async schema({ schema, generator }) {
|
|
50
|
+
const { pluginManager, plugin } = generator.context;
|
|
51
|
+
return [{
|
|
52
|
+
...pluginManager.getFile({
|
|
53
|
+
name: camelCase(schema.name),
|
|
54
|
+
extname: ".json",
|
|
55
|
+
mode: "split",
|
|
56
|
+
pluginKey: plugin.key
|
|
57
|
+
}),
|
|
58
|
+
sources: [{
|
|
59
|
+
name: camelCase(schema.name),
|
|
60
|
+
isExportable: false,
|
|
61
|
+
isIndexable: false,
|
|
62
|
+
value: JSON.stringify(schema.value)
|
|
63
|
+
}],
|
|
64
|
+
banner: getBanner({
|
|
65
|
+
oas: generator.context.oas,
|
|
66
|
+
output: plugin.options.output,
|
|
67
|
+
config: pluginManager.config
|
|
68
|
+
}),
|
|
69
|
+
format: getFooter({
|
|
70
|
+
oas: generator.context.oas,
|
|
71
|
+
output: plugin.options.output
|
|
72
|
+
})
|
|
73
|
+
}];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
//#endregion
|
|
77
|
+
export { createReactGenerator as n, createGenerator as r, jsonGenerator as t };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=generators-D7C3CXsN.js.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { isFunction } from "remeda";
|
|
4
|
+
//#region ../../internals/utils/src/casing.ts
|
|
5
|
+
/**
|
|
6
|
+
* Shared implementation for camelCase and PascalCase conversion.
|
|
7
|
+
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
8
|
+
* and capitalizes each word according to `pascal`.
|
|
9
|
+
*
|
|
10
|
+
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
11
|
+
*/
|
|
12
|
+
function toCamelOrPascal(text, pascal) {
|
|
13
|
+
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
14
|
+
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
15
|
+
if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
|
|
16
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
17
|
+
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Splits `text` on `.` and applies `transformPart` to each segment.
|
|
21
|
+
* The last segment receives `isLast = true`, all earlier segments receive `false`.
|
|
22
|
+
* Segments are joined with `/` to form a file path.
|
|
23
|
+
*/
|
|
24
|
+
function applyToFileParts(text, transformPart) {
|
|
25
|
+
const parts = text.split(".");
|
|
26
|
+
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts `text` to camelCase.
|
|
30
|
+
* When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* camelCase('hello-world') // 'helloWorld'
|
|
34
|
+
* camelCase('pet.petId', { isFile: true }) // 'pet/petId'
|
|
35
|
+
*/
|
|
36
|
+
function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
37
|
+
if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
|
|
38
|
+
prefix,
|
|
39
|
+
suffix
|
|
40
|
+
} : {}));
|
|
41
|
+
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Converts `text` to PascalCase.
|
|
45
|
+
* When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* pascalCase('hello-world') // 'HelloWorld'
|
|
49
|
+
* pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'
|
|
50
|
+
*/
|
|
51
|
+
function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
52
|
+
if (isFile) return applyToFileParts(text, (part, isLast) => isLast ? pascalCase(part, {
|
|
53
|
+
prefix,
|
|
54
|
+
suffix
|
|
55
|
+
}) : camelCase(part));
|
|
56
|
+
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/utils/getBanner.ts
|
|
60
|
+
/**
|
|
61
|
+
* Generate a default banner for files created by Kubb
|
|
62
|
+
* @returns A string with the default banner
|
|
63
|
+
*/
|
|
64
|
+
function getDefaultBanner({ title, description, version, config }) {
|
|
65
|
+
try {
|
|
66
|
+
let source = "";
|
|
67
|
+
if ("path" in config.input) source = path.basename(config.input.path);
|
|
68
|
+
else if ("data" in config.input) source = "text content";
|
|
69
|
+
let banner = "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n";
|
|
70
|
+
if (config.output.defaultBanner === "simple") {
|
|
71
|
+
banner += "*/\n";
|
|
72
|
+
return banner;
|
|
73
|
+
}
|
|
74
|
+
if (source) banner += `* Source: ${source}\n`;
|
|
75
|
+
if (title) banner += `* Title: ${title}\n`;
|
|
76
|
+
if (description) {
|
|
77
|
+
const formattedDescription = description.replace(/\n/gm, "\n* ");
|
|
78
|
+
banner += `* Description: ${formattedDescription}\n`;
|
|
79
|
+
}
|
|
80
|
+
if (version) banner += `* OpenAPI spec version: ${version}\n`;
|
|
81
|
+
banner += "*/\n";
|
|
82
|
+
return banner;
|
|
83
|
+
} catch (_error) {
|
|
84
|
+
return "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/";
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function getBanner({ output, oas, config }) {
|
|
88
|
+
let banner = "";
|
|
89
|
+
if (config?.output?.defaultBanner !== false && config) {
|
|
90
|
+
const { title, description, version } = oas.api?.info || {};
|
|
91
|
+
banner = getDefaultBanner({
|
|
92
|
+
title,
|
|
93
|
+
description,
|
|
94
|
+
version,
|
|
95
|
+
config
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (!output.banner) return banner;
|
|
99
|
+
if (isFunction(output.banner)) return `${output.banner(oas)}\n${banner}`;
|
|
100
|
+
return `${output.banner}\n${banner}`;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/utils/getFooter.ts
|
|
104
|
+
function getFooter({ output, oas }) {
|
|
105
|
+
if (!output.footer) return;
|
|
106
|
+
if (isFunction(output.footer)) return output.footer(oas);
|
|
107
|
+
return output.footer;
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
export { pascalCase as i, getBanner as n, camelCase as r, getFooter as t };
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=getFooter-Pw3tLCiV.js.map
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import { useFabric } from "@kubb/react-fabric";
|
|
3
|
+
import { usePlugin, usePluginManager } from "@kubb/core/hooks";
|
|
4
|
+
//#region src/hooks/useOas.ts
|
|
5
|
+
function useOas() {
|
|
6
|
+
const { meta } = useFabric();
|
|
7
|
+
return meta.oas;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/hooks/useOperationManager.ts
|
|
11
|
+
/**
|
|
12
|
+
* `useOperationManager` returns helper functions to get the operation file and operation name.
|
|
13
|
+
*/
|
|
14
|
+
function useOperationManager(generator) {
|
|
15
|
+
const plugin = usePlugin();
|
|
16
|
+
const pluginManager = usePluginManager();
|
|
17
|
+
const getName = (operation, { prefix = "", suffix = "", pluginKey = plugin.key, type }) => {
|
|
18
|
+
return pluginManager.resolveName({
|
|
19
|
+
name: `${prefix} ${operation.getOperationId()} ${suffix}`,
|
|
20
|
+
pluginKey,
|
|
21
|
+
type
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const getGroup = (operation) => {
|
|
25
|
+
return {
|
|
26
|
+
tag: operation.getTags().at(0)?.name,
|
|
27
|
+
path: operation.path
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const getSchemas = (operation, params) => {
|
|
31
|
+
if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
|
|
32
|
+
return generator.getSchemas(operation, { resolveName: (name) => pluginManager.resolveName({
|
|
33
|
+
name,
|
|
34
|
+
pluginKey: params?.pluginKey,
|
|
35
|
+
type: params?.type
|
|
36
|
+
}) });
|
|
37
|
+
};
|
|
38
|
+
const getFile = (operation, { prefix, suffix, pluginKey = plugin.key, extname = ".ts" } = {}) => {
|
|
39
|
+
const name = getName(operation, {
|
|
40
|
+
type: "file",
|
|
41
|
+
pluginKey,
|
|
42
|
+
prefix,
|
|
43
|
+
suffix
|
|
44
|
+
});
|
|
45
|
+
const group = getGroup(operation);
|
|
46
|
+
const file = pluginManager.getFile({
|
|
47
|
+
name,
|
|
48
|
+
extname,
|
|
49
|
+
pluginKey,
|
|
50
|
+
options: {
|
|
51
|
+
type: "file",
|
|
52
|
+
pluginKey,
|
|
53
|
+
group
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
...file,
|
|
58
|
+
meta: {
|
|
59
|
+
...file.meta,
|
|
60
|
+
name,
|
|
61
|
+
pluginKey,
|
|
62
|
+
group
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const groupSchemasByName = (operation, { pluginKey = plugin.key, type }) => {
|
|
67
|
+
if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
|
|
68
|
+
const schemas = generator.getSchemas(operation);
|
|
69
|
+
const errors = (schemas.errors || []).reduce((prev, acc) => {
|
|
70
|
+
if (!acc.statusCode) return prev;
|
|
71
|
+
prev[acc.statusCode] = pluginManager.resolveName({
|
|
72
|
+
name: acc.name,
|
|
73
|
+
pluginKey,
|
|
74
|
+
type
|
|
75
|
+
});
|
|
76
|
+
return prev;
|
|
77
|
+
}, {});
|
|
78
|
+
const responses = (schemas.responses || []).reduce((prev, acc) => {
|
|
79
|
+
if (!acc.statusCode) return prev;
|
|
80
|
+
prev[acc.statusCode] = pluginManager.resolveName({
|
|
81
|
+
name: acc.name,
|
|
82
|
+
pluginKey,
|
|
83
|
+
type
|
|
84
|
+
});
|
|
85
|
+
return prev;
|
|
86
|
+
}, {});
|
|
87
|
+
return {
|
|
88
|
+
request: schemas.request?.name ? pluginManager.resolveName({
|
|
89
|
+
name: schemas.request.name,
|
|
90
|
+
pluginKey,
|
|
91
|
+
type
|
|
92
|
+
}) : void 0,
|
|
93
|
+
parameters: {
|
|
94
|
+
path: schemas.pathParams?.name ? pluginManager.resolveName({
|
|
95
|
+
name: schemas.pathParams.name,
|
|
96
|
+
pluginKey,
|
|
97
|
+
type
|
|
98
|
+
}) : void 0,
|
|
99
|
+
query: schemas.queryParams?.name ? pluginManager.resolveName({
|
|
100
|
+
name: schemas.queryParams.name,
|
|
101
|
+
pluginKey,
|
|
102
|
+
type
|
|
103
|
+
}) : void 0,
|
|
104
|
+
header: schemas.headerParams?.name ? pluginManager.resolveName({
|
|
105
|
+
name: schemas.headerParams.name,
|
|
106
|
+
pluginKey,
|
|
107
|
+
type
|
|
108
|
+
}) : void 0
|
|
109
|
+
},
|
|
110
|
+
responses: {
|
|
111
|
+
...responses,
|
|
112
|
+
["default"]: pluginManager.resolveName({
|
|
113
|
+
name: schemas.response.name,
|
|
114
|
+
pluginKey,
|
|
115
|
+
type
|
|
116
|
+
}),
|
|
117
|
+
...errors
|
|
118
|
+
},
|
|
119
|
+
errors
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
getName,
|
|
124
|
+
getFile,
|
|
125
|
+
getSchemas,
|
|
126
|
+
groupSchemasByName,
|
|
127
|
+
getGroup
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/hooks/useRootNode.ts
|
|
132
|
+
/**
|
|
133
|
+
* Returns the universal `@kubb/ast` `RootNode` produced by the configured adapter.
|
|
134
|
+
*
|
|
135
|
+
* Use this hook inside generator components when you want to consume the
|
|
136
|
+
* format-agnostic AST directly instead of going through `useOas()`.
|
|
137
|
+
*
|
|
138
|
+
* Returns `undefined` when no adapter was configured (legacy OAS-only mode).
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```tsx
|
|
142
|
+
* function MyComponent() {
|
|
143
|
+
* const rootNode = useRootNode()
|
|
144
|
+
* if (!rootNode) return null
|
|
145
|
+
* return <>{rootNode.schemas.map(s => <Schema key={s.name} node={s} />)}</>
|
|
146
|
+
* }
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
function useRootNode() {
|
|
150
|
+
const { meta } = useFabric();
|
|
151
|
+
return meta.pluginManager?.rootNode;
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/hooks/useSchemaManager.ts
|
|
155
|
+
/**
|
|
156
|
+
* `useSchemaManager` returns helper functions to get the schema file and schema name.
|
|
157
|
+
*/
|
|
158
|
+
function useSchemaManager() {
|
|
159
|
+
const plugin = usePlugin();
|
|
160
|
+
const pluginManager = usePluginManager();
|
|
161
|
+
const getName = (name, { pluginKey = plugin.key, type }) => {
|
|
162
|
+
return pluginManager.resolveName({
|
|
163
|
+
name,
|
|
164
|
+
pluginKey,
|
|
165
|
+
type
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
const getFile = (name, { mode = "split", pluginKey = plugin.key, extname = ".ts", group } = {}) => {
|
|
169
|
+
const resolvedName = mode === "single" ? "" : getName(name, {
|
|
170
|
+
type: "file",
|
|
171
|
+
pluginKey
|
|
172
|
+
});
|
|
173
|
+
const file = pluginManager.getFile({
|
|
174
|
+
name: resolvedName,
|
|
175
|
+
extname,
|
|
176
|
+
pluginKey,
|
|
177
|
+
options: {
|
|
178
|
+
type: "file",
|
|
179
|
+
pluginKey,
|
|
180
|
+
group
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
...file,
|
|
185
|
+
meta: {
|
|
186
|
+
...file.meta,
|
|
187
|
+
name: resolvedName,
|
|
188
|
+
pluginKey
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
return {
|
|
193
|
+
getName,
|
|
194
|
+
getFile
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
export { useOas, useOperationManager, useRootNode, useSchemaManager };
|
|
199
|
+
|
|
200
|
+
//# sourceMappingURL=hooks.js.map
|