@kubb/plugin-oas 4.3.1 → 4.4.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/{Oas-DoN76W2_.js → Oas-CHC1IC5D.js} +5 -9
- package/dist/Oas-CHC1IC5D.js.map +1 -0
- package/dist/{Oas--cvTRMTA.cjs → Oas-CQrRP_NH.cjs} +13 -17
- package/dist/Oas-CQrRP_NH.cjs.map +1 -0
- package/dist/{OperationGenerator-XkW6FZJh.d.cts → OperationGenerator-CRZpkIpZ.d.ts} +182 -109
- package/dist/{OperationGenerator-ki8g970_.d.ts → OperationGenerator-S_1PevQN.d.cts} +182 -109
- package/dist/{Schema-CHstINXC.d.ts → Schema-CZsDEhET.d.cts} +7 -6
- package/dist/{Schema-BXYfUkqN.d.cts → Schema-DBvtiLS7.d.ts} +7 -6
- package/dist/{SchemaGenerator-DsK0wuii.cjs → SchemaGenerator-DWj6buY0.cjs} +22 -5
- package/dist/SchemaGenerator-DWj6buY0.cjs.map +1 -0
- package/dist/{SchemaGenerator-B07tXh1b.js → SchemaGenerator-b7XixzRv.js} +21 -4
- package/dist/SchemaGenerator-b7XixzRv.js.map +1 -0
- package/dist/{SchemaMapper-qjB3rBph.d.ts → SchemaMapper-CX7sIIuZ.d.cts} +5 -118
- package/dist/{SchemaMapper-MiRB5_Zp.d.cts → SchemaMapper-CtfTw3hq.d.ts} +5 -118
- package/dist/{SchemaMapper-CM1eXksi.js → SchemaMapper-Cx4X1al6.js} +1 -1
- package/dist/SchemaMapper-Cx4X1al6.js.map +1 -0
- package/dist/{SchemaMapper-CpAbmGiH.cjs → SchemaMapper-DoL-a6qq.cjs} +1 -1
- package/dist/SchemaMapper-DoL-a6qq.cjs.map +1 -0
- package/dist/chunk-BEV-X5tz.js +27 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +8 -11
- package/dist/components.d.ts +8 -11
- package/dist/components.js +1 -1
- package/dist/generators-B27La9Vd.cjs +99 -0
- package/dist/generators-B27La9Vd.cjs.map +1 -0
- package/dist/generators-C61FxVIj.js +80 -0
- package/dist/generators-C61FxVIj.js.map +1 -0
- package/dist/generators.cjs +9 -3
- package/dist/generators.d.cts +3 -8
- package/dist/generators.d.ts +3 -8
- package/dist/generators.js +5 -4
- package/dist/{getFooter-pQXwqM81.cjs → getFooter-CwjCW4h5.cjs} +3 -3
- package/dist/{getFooter-pQXwqM81.cjs.map → getFooter-CwjCW4h5.cjs.map} +1 -1
- package/dist/{getFooter-CvTKkK7-.js → getFooter-D5MdeUVv.js} +2 -2
- package/dist/{getFooter-CvTKkK7-.js.map → getFooter-D5MdeUVv.js.map} +1 -1
- package/dist/{getSchemas-CvUX0jWa.js → getSchemas-Bdg6n9Qk.js} +1 -1
- package/dist/{getSchemas-CvUX0jWa.js.map → getSchemas-Bdg6n9Qk.js.map} +1 -1
- package/dist/{getSchemas-08CU8KWq.cjs → getSchemas-DY8s2CSl.cjs} +1 -1
- package/dist/{getSchemas-08CU8KWq.cjs.map → getSchemas-DY8s2CSl.cjs.map} +1 -1
- package/dist/hooks.cjs +12 -27
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +11 -31
- package/dist/hooks.d.ts +11 -31
- package/dist/hooks.js +9 -23
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +37 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -9
- package/dist/index.d.ts +3 -9
- package/dist/index.js +33 -9
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{parseFromConfig-DSI6Meg0.js → parseFromConfig-CqiiLCPe.js} +1 -1
- package/dist/{parseFromConfig-DSI6Meg0.js.map → parseFromConfig-CqiiLCPe.js.map} +1 -1
- package/dist/{parseFromConfig-o3tU1XJt.cjs → parseFromConfig-RR31a98-.cjs} +1 -1
- package/dist/{parseFromConfig-o3tU1XJt.cjs.map → parseFromConfig-RR31a98-.cjs.map} +1 -1
- package/dist/utils-DYf-j63H.cjs +115 -0
- package/dist/utils-DYf-j63H.cjs.map +1 -0
- package/dist/utils-DaV25sy8.js +95 -0
- package/dist/utils-DaV25sy8.js.map +1 -0
- package/dist/utils.cjs +3 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +4 -3
- package/dist/utils.d.ts +4 -3
- package/dist/utils.js +3 -3
- package/dist/utils.js.map +1 -1
- package/package.json +14 -11
- package/src/OperationGenerator.ts +36 -7
- package/src/SchemaGenerator.ts +26 -2
- package/src/SchemaMapper.ts +1 -1
- package/src/components/Oas.tsx +5 -12
- package/src/components/Operation.tsx +3 -3
- package/src/components/Schema.tsx +3 -4
- package/src/generators/createGenerator.ts +34 -0
- package/src/generators/createReactGenerator.ts +41 -0
- package/src/generators/index.ts +4 -0
- package/src/generators/jsonGenerator.ts +1 -1
- package/src/generators/types.ts +35 -0
- package/src/generators/utils.tsx +114 -0
- package/src/hooks/index.ts +1 -2
- package/src/hooks/useOas.ts +5 -11
- package/src/hooks/useOperation.ts +1 -1
- package/src/hooks/useOperationManager.ts +2 -2
- package/src/hooks/useSchema.ts +1 -1
- package/src/hooks/useSchemaManager.ts +1 -1
- package/src/index.ts +3 -5
- package/src/plugin.ts +2 -0
- package/src/types.ts +2 -2
- package/src/utils/getParams.ts +1 -1
- package/dist/Oas--cvTRMTA.cjs.map +0 -1
- package/dist/Oas-DoN76W2_.js.map +0 -1
- package/dist/SchemaGenerator-B07tXh1b.js.map +0 -1
- package/dist/SchemaGenerator-DsK0wuii.cjs.map +0 -1
- package/dist/SchemaMapper-CM1eXksi.js.map +0 -1
- package/dist/SchemaMapper-CpAbmGiH.cjs.map +0 -1
- package/dist/generators-BUNmB1lx.js +0 -154
- package/dist/generators-BUNmB1lx.js.map +0 -1
- package/dist/generators-CoiXCnDY.cjs +0 -175
- package/dist/generators-CoiXCnDY.cjs.map +0 -1
- package/src/generator.tsx +0 -139
- package/src/hooks/useOperations.ts +0 -40
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSchemas-
|
|
1
|
+
{"version":3,"file":"getSchemas-Bdg6n9Qk.js","names":["schemas: Record<string, OasTypes.SchemaObject>"],"sources":["../src/utils/getSchemaFactory.ts","../src/utils/getSchemas.ts"],"sourcesContent":["import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\n/**\n * Creates a factory function that generates a versioned OpenAPI schema result.\n *\n * The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1').\n *\n * @returns A function that takes an optional schema and returns a versioned schema result.\n */\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schemaObject: oas.dereferenceWithRef(schema),\n version,\n } as SchemaResult<TWithRef>\n }\n}\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n"],"mappings":";;;;;;;;;;AA8BA,SAAgB,iBAAmD,KAA6D;AAC9H,SAAQ,WAA0B;EAChC,MAAM,UAAU,sBAAsB,IAAI,IAAI,GAAG,QAAQ;AAEzD,SAAO;GACL,cAAc,IAAI,mBAAmB,OAAO;GAC5C;GACD;;;;;;AC3BL,SAAgB,WAAW,EAAE,KAAK,aAAa,WAAW;CAAC;CAAW;CAAiB;CAAY,IAA4D;CAC7J,MAAM,aAAa,IAAI,eAAe,CAAC;CAEvC,IAAIA,UAAiD,EAAE;AAEvD,KAAI,SAAS,SAAS,UAAU,CAC9B,WAAU;EACR,GAAG;EACH,GAAK,YAAY,WAAqD,EAAE;EACzE;CAGH,MAAM,gBAAgB,YAAY,iBAAiB,EAAE;AACrD,KAAI,SAAS,SAAS,YAAY,EAAE;EAClC,MAAM,YAAY,YAAY,aAAa,EAAE;AAE7C,SAAO,QAAQ,UAAU,CAAC,SAAS,CAAC,MAAM,cAAiD;AACzF,OAAI,SAAS,WAAW,CAAC,QAAQ,OAAO;IACtC,MAAM,mBAAmB,OAAO,KAAK,SAAS,QAAQ,CAAC,MAAM;AAC7D,YAAQ,QAAQ,SAAS,UAAU,eAAe,mBAAmB;;IAEvE;;AAGJ,KAAI,SAAS,SAAS,gBAAgB,CACpC,QAAO,QAAQ,cAAc,CAAC,SAAS,CAAC,MAAM,aAAmD;AAC/F,MAAI,QAAQ,WAAW,CAAC,QAAQ,OAAO;GACrC,MAAM,mBAAmB,OAAO,KAAK,QAAQ,QAAQ,CAAC,MAAM;AAC5D,WAAQ,QAAQ,QAAQ,UAAU,eAAe,mBAAmB;;GAEtE;AAGJ,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSchemas-
|
|
1
|
+
{"version":3,"file":"getSchemas-DY8s2CSl.cjs","names":["schemas: Record<string, OasTypes.SchemaObject>"],"sources":["../src/utils/getSchemaFactory.ts","../src/utils/getSchemas.ts"],"sourcesContent":["import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\n/**\n * Creates a factory function that generates a versioned OpenAPI schema result.\n *\n * The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1').\n *\n * @returns A function that takes an optional schema and returns a versioned schema result.\n */\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schemaObject: oas.dereferenceWithRef(schema),\n version,\n } as SchemaResult<TWithRef>\n }\n}\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgB,iBAAmD,KAA6D;AAC9H,SAAQ,WAA0B;EAChC,MAAM,gDAAgC,IAAI,IAAI,GAAG,QAAQ;AAEzD,SAAO;GACL,cAAc,IAAI,mBAAmB,OAAO;GAC5C;GACD;;;;;;AC3BL,SAAgB,WAAW,EAAE,KAAK,aAAa,WAAW;CAAC;CAAW;CAAiB;CAAY,IAA4D;CAC7J,MAAM,aAAa,IAAI,eAAe,CAAC;CAEvC,IAAIA,UAAiD,EAAE;AAEvD,KAAI,SAAS,SAAS,UAAU,CAC9B,WAAU;EACR,GAAG;EACH,GAAK,YAAY,WAAqD,EAAE;EACzE;CAGH,MAAM,gBAAgB,YAAY,iBAAiB,EAAE;AACrD,KAAI,SAAS,SAAS,YAAY,EAAE;EAClC,MAAM,YAAY,YAAY,aAAa,EAAE;AAE7C,SAAO,QAAQ,UAAU,CAAC,SAAS,CAAC,MAAM,cAAiD;AACzF,OAAI,SAAS,WAAW,CAAC,QAAQ,OAAO;IACtC,MAAM,mBAAmB,OAAO,KAAK,SAAS,QAAQ,CAAC,MAAM;AAC7D,YAAQ,QAAQ,SAAS,UAAU,eAAe,mBAAmB;;IAEvE;;AAGJ,KAAI,SAAS,SAAS,gBAAgB,CACpC,QAAO,QAAQ,cAAc,CAAC,SAAS,CAAC,MAAM,aAAmD;AAC/F,MAAI,QAAQ,WAAW,CAAC,QAAQ,OAAO;GACrC,MAAM,mBAAmB,OAAO,KAAK,QAAQ,QAAQ,CAAC,MAAM;AAC5D,WAAQ,QAAQ,QAAQ,UAAU,eAAe,mBAAmB;;GAEtE;AAGJ,QAAO"}
|
package/dist/hooks.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
require('./
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const require_Oas = require('./Oas-CQrRP_NH.cjs');
|
|
3
|
+
require('./utils-DYf-j63H.cjs');
|
|
4
|
+
const require_SchemaGenerator = require('./SchemaGenerator-DWj6buY0.cjs');
|
|
5
|
+
const require_SchemaMapper = require('./SchemaMapper-DoL-a6qq.cjs');
|
|
6
|
+
require('./getSchemas-DY8s2CSl.cjs');
|
|
7
|
+
let __kubb_react_fabric = require("@kubb/react-fabric");
|
|
8
|
+
__kubb_react_fabric = require_chunk.__toESM(__kubb_react_fabric);
|
|
8
9
|
let __kubb_core_hooks = require("@kubb/core/hooks");
|
|
9
10
|
__kubb_core_hooks = require_chunk.__toESM(__kubb_core_hooks);
|
|
10
11
|
|
|
11
12
|
//#region src/hooks/useOas.ts
|
|
12
13
|
function useOas() {
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
return oas;
|
|
14
|
+
const { meta } = (0, __kubb_react_fabric.useApp)();
|
|
15
|
+
return meta.oas;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
//#endregion
|
|
@@ -21,7 +21,7 @@ function useOas() {
|
|
|
21
21
|
* `useOperation` will return the current `Operation`
|
|
22
22
|
*/
|
|
23
23
|
function useOperation() {
|
|
24
|
-
const { operation } = (0,
|
|
24
|
+
const { operation } = (0, __kubb_react_fabric.useContext)(require_Oas.Operation.Context);
|
|
25
25
|
if (!operation) throw new Error("Operation is not defined");
|
|
26
26
|
return operation;
|
|
27
27
|
}
|
|
@@ -34,7 +34,7 @@ function useOperation() {
|
|
|
34
34
|
function useOperationManager() {
|
|
35
35
|
const plugin = (0, __kubb_core_hooks.usePlugin)();
|
|
36
36
|
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
37
|
-
const { generator } = (0,
|
|
37
|
+
const { generator } = (0, __kubb_react_fabric.useContext)(require_Oas.Oas.Context);
|
|
38
38
|
const getName = (operation, { prefix = "", suffix = "", pluginKey = plugin.key, type }) => {
|
|
39
39
|
return pluginManager.resolveName({
|
|
40
40
|
name: `${prefix} ${operation.getOperationId()} ${suffix}`,
|
|
@@ -149,27 +149,13 @@ function useOperationManager() {
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region src/hooks/useOperations.ts
|
|
154
|
-
/**
|
|
155
|
-
* `useOperations` will return all the Operations
|
|
156
|
-
*/
|
|
157
|
-
function useOperations({ method, path } = {}) {
|
|
158
|
-
const { operations } = (0, __kubb_react.useContext)(require_Oas.Oas.Context);
|
|
159
|
-
if (!operations) throw new Error("Operations is not defined");
|
|
160
|
-
let items = operations;
|
|
161
|
-
if (path) items = items.filter((item) => item.path === path);
|
|
162
|
-
if (method) items = items.filter((item) => item.method === method);
|
|
163
|
-
return items;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
152
|
//#endregion
|
|
167
153
|
//#region src/hooks/useSchema.ts
|
|
168
154
|
/**
|
|
169
155
|
* `useSchema` will return the current `schema properties`
|
|
170
156
|
*/
|
|
171
157
|
function useSchema() {
|
|
172
|
-
return (0,
|
|
158
|
+
return (0, __kubb_react_fabric.useContext)(require_Oas.Schema.Context);
|
|
173
159
|
}
|
|
174
160
|
|
|
175
161
|
//#endregion
|
|
@@ -231,7 +217,6 @@ function useSchemaManager() {
|
|
|
231
217
|
exports.useOas = useOas;
|
|
232
218
|
exports.useOperation = useOperation;
|
|
233
219
|
exports.useOperationManager = useOperationManager;
|
|
234
|
-
exports.useOperations = useOperations;
|
|
235
220
|
exports.useSchema = useSchema;
|
|
236
221
|
exports.useSchemaManager = useSchemaManager;
|
|
237
222
|
//# sourceMappingURL=hooks.cjs.map
|
package/dist/hooks.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.cjs","names":["Oas","Operation","Oas","getName: UseOperationManagerResult['getName']","getGroup: UseOperationManagerResult['getGroup']","getSchemas: UseOperationManagerResult['getSchemas']","getFile: UseOperationManagerResult['getFile']","groupSchemasByName: UseOperationManagerResult['groupSchemasByName']","Oas","Schema","getName: UseSchemaManagerResult['getName']","getFile: UseSchemaManagerResult['getFile']","getImports: UseSchemaManagerResult['getImports']","SchemaGenerator","schemaKeywords"],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts","../src/hooks/useSchema.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport { useContext } from '@kubb/react'\nimport { Oas } from '../components/Oas.tsx'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\n const { generator } = useContext(Oas.Context)\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {\n return {\n tag: operation.getTags().at(0)?.name,\n path: operation.path,\n }\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\n const group = getGroup(operation)\n\n const file = pluginManager.getFile({\n name,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n const responses = (schemas.responses || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas,\n groupSchemasByName,\n getGroup,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n","import { useContext } from '@kubb/react'\n\nimport { Schema } from '../components/Schema.tsx'\n\nimport type { SchemaContextProps } from '../components/Schema.tsx'\n\ntype UseSchemaResult = SchemaContextProps\n\n/**\n * `useSchema` will return the current `schema properties`\n */\nexport function useSchema(): UseSchemaResult {\n const props = useContext(Schema.Context)\n\n return props as UseSchemaResult\n}\n","import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport { type Schema, schemaKeywords } from '../SchemaMapper'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginKey?: Plugin['key']\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n getImports: (tree: Array<Schema>) => Array<KubbFile.Import>\n}\n\n/**\n * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n const getImports: UseSchemaManagerResult['getImports'] = (tree) => {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n }\n\n return {\n getName,\n getFile,\n getImports,\n }\n}\n"],"mappings":";;;;;;;;;;;AAMA,SAAgB,SAAkB;CAChC,MAAM,EAAE,qCAAmBA,gBAAI,QAAQ;AAEvC,KAAI,CAAC,IACH,OAAM,IAAI,MAAM,qBAAqB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,SAAQ,MAAM,QAAQ,SAAS,KAAK,SAAS,KAAK;AAGpD,KAAI,OACF,SAAQ,MAAM,QAAQ,SAAS,KAAK,WAAW,OAAO;AAGxD,QAAO;;;;;;;;AC3BT,SAAgB,YAA6B;AAG3C,qCAFyBC,mBAAO,QAAQ;;;;;;;;ACuB1C,SAAgB,mBAA2C;CACzD,MAAM,2CAAoB;CAC1B,MAAM,yDAAkC;CAExC,MAAMC,WAA8C,MAAM,EAAE,YAAY,OAAO,KAAK,WAAW;AAC7F,SAAO,cAAc,YAAY;GAC/B;GACA;GACA;GACD,CAAC;;CAGJ,MAAMC,WAA8C,MAAM,EAAE,OAAO,SAAS,YAAY,OAAO,KAAK,UAAU,OAAO,UAAU,EAAE,KAAK;EACpI,MAAM,eAAe,SAAS,WAAW,KAAK,QAAQ,MAAM;GAAE,MAAM;GAAQ;GAAW,CAAC;EAExF,MAAM,OAAO,cAAc,QAAQ;GACjC,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAW;IAAO;GAC5C,CAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;;CAGH,MAAMC,cAAoD,SAAS;AAGjE,SAFaC,wCAAgB,WAAW,MAAMC,oCAAe,IAAI,EAG7D,KAAK,SAAS;AACd,OAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAChC;AAGF,UAAO;IACL,MAAM,CAAC,KAAK,KAAK,KAAK;IACtB,MAAM,KAAK,KAAK;IACjB;IACD,CACD,OAAO,QAAQ;;AAGpB,QAAO;EACL;EACA;EACA;EACD"}
|
|
1
|
+
{"version":3,"file":"hooks.cjs","names":["Operation","Oas","getName: UseOperationManagerResult['getName']","getGroup: UseOperationManagerResult['getGroup']","getSchemas: UseOperationManagerResult['getSchemas']","getFile: UseOperationManagerResult['getFile']","groupSchemasByName: UseOperationManagerResult['groupSchemasByName']","Schema","getName: UseSchemaManagerResult['getName']","getFile: UseSchemaManagerResult['getFile']","getImports: UseSchemaManagerResult['getImports']","SchemaGenerator","schemaKeywords"],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useSchema.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useOas(): Oas {\n const { meta } = useApp<{ oas: Oas }>()\n\n return meta.oas\n}\n","import { useContext } from '@kubb/react-fabric'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport { useContext } from '@kubb/react-fabric'\nimport { Oas } from '../components/Oas.tsx'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\n const { generator } = useContext(Oas.Context)\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {\n return {\n tag: operation.getTags().at(0)?.name,\n path: operation.path,\n }\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\n const group = getGroup(operation)\n\n const file = pluginManager.getFile({\n name,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n const responses = (schemas.responses || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas,\n groupSchemasByName,\n getGroup,\n }\n}\n","import { useContext } from '@kubb/react-fabric'\n\nimport { Schema } from '../components/Schema.tsx'\n\nimport type { SchemaContextProps } from '../components/Schema.tsx'\n\ntype UseSchemaResult = SchemaContextProps\n\n/**\n * `useSchema` will return the current `schema properties`\n */\nexport function useSchema(): UseSchemaResult {\n const props = useContext(Schema.Context)\n\n return props as UseSchemaResult\n}\n","import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport { type Schema, schemaKeywords } from '../SchemaMapper'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginKey?: Plugin['key']\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n getImports: (tree: Array<Schema>) => Array<KubbFile.Import>\n}\n\n/**\n * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n const getImports: UseSchemaManagerResult['getImports'] = (tree) => {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n }\n\n return {\n getName,\n getFile,\n getImports,\n }\n}\n"],"mappings":";;;;;;;;;;;;AAIA,SAAgB,SAAc;CAC5B,MAAM,EAAE,0CAA+B;AAEvC,QAAO,KAAK;;;;;;;;ACEd,SAAgB,eAA8B;CAC5C,MAAM,EAAE,kDAAyBA,sBAAU,QAAQ;AAEnD,KAAI,CAAC,UACH,OAAM,IAAI,MAAM,2BAA2B;AAG7C,QAAO;;;;;;;;ACiDT,SAAgB,sBAAiD;CAC/D,MAAM,2CAAoB;CAC1B,MAAM,yDAAkC;CACxC,MAAM,EAAE,kDAAyBC,gBAAI,Q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GACjC,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAW;IAAO;GAC5C,CAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;;CAGH,MAAMC,cAAoD,SAAS;AAGjE,SAFaC,wCAAgB,WAAW,MAAMC,oCAAe,IAAI,EAG7D,KAAK,SAAS;AACd,OAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAChC;AAGF,UAAO;IACL,MAAM,CAAC,KAAK,KAAK,KAAK;IACtB,MAAM,KAAK,KAAK;IACjB;IACD,CACD,OAAO,QAAQ;;AAGpB,QAAO;EACL;EACA;EACA;EACD"}
|
package/dist/hooks.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as SchemaContextProps } from "./Schema-
|
|
1
|
+
import { M as Plugin, N as ResolveNameParams, P as Oas, R as Operation, k as FileMetaBase, y as OperationSchemas } from "./OperationGenerator-S_1PevQN.cjs";
|
|
2
|
+
import { t as Schema } from "./SchemaMapper-CX7sIIuZ.cjs";
|
|
3
|
+
import { n as SchemaContextProps } from "./Schema-CZsDEhET.cjs";
|
|
4
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
4
5
|
|
|
5
6
|
//#region src/hooks/useOas.d.ts
|
|
6
7
|
declare function useOas(): Oas;
|
|
@@ -43,12 +44,12 @@ type UseOperationManagerResult = {
|
|
|
43
44
|
prefix?: string;
|
|
44
45
|
suffix?: string;
|
|
45
46
|
pluginKey?: Plugin['key'];
|
|
46
|
-
extname?: Extname;
|
|
47
|
+
extname?: KubbFile.Extname;
|
|
47
48
|
group?: {
|
|
48
49
|
tag?: string;
|
|
49
50
|
path?: string;
|
|
50
51
|
};
|
|
51
|
-
}) => File<FileMeta$1>;
|
|
52
|
+
}) => KubbFile.File<FileMeta$1>;
|
|
52
53
|
groupSchemasByName: (operation: Operation, params: {
|
|
53
54
|
pluginKey?: Plugin['key'];
|
|
54
55
|
type: ResolveNameParams['type'];
|
|
@@ -64,27 +65,6 @@ type UseOperationManagerResult = {
|
|
|
64
65
|
*/
|
|
65
66
|
declare function useOperationManager(): UseOperationManagerResult;
|
|
66
67
|
//#endregion
|
|
67
|
-
//#region src/hooks/useOperations.d.ts
|
|
68
|
-
type UseOperationsProps = {
|
|
69
|
-
/**
|
|
70
|
-
* Filter based on path
|
|
71
|
-
* Weight: 2
|
|
72
|
-
*/
|
|
73
|
-
path?: string;
|
|
74
|
-
/**
|
|
75
|
-
* Filter based on method
|
|
76
|
-
* Weight: 1
|
|
77
|
-
*/
|
|
78
|
-
method?: HttpMethod;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* `useOperations` will return all the Operations
|
|
82
|
-
*/
|
|
83
|
-
declare function useOperations({
|
|
84
|
-
method,
|
|
85
|
-
path
|
|
86
|
-
}?: UseOperationsProps): Operation[];
|
|
87
|
-
//#endregion
|
|
88
68
|
//#region src/hooks/useSchema.d.ts
|
|
89
69
|
type UseSchemaResult = SchemaContextProps;
|
|
90
70
|
/**
|
|
@@ -108,19 +88,19 @@ type UseSchemaManagerResult = {
|
|
|
108
88
|
}) => string;
|
|
109
89
|
getFile: (name: string, params?: {
|
|
110
90
|
pluginKey?: Plugin['key'];
|
|
111
|
-
mode?: Mode;
|
|
112
|
-
extname?: Extname;
|
|
91
|
+
mode?: KubbFile.Mode;
|
|
92
|
+
extname?: KubbFile.Extname;
|
|
113
93
|
group?: {
|
|
114
94
|
tag?: string;
|
|
115
95
|
path?: string;
|
|
116
96
|
};
|
|
117
|
-
}) => File<FileMeta>;
|
|
118
|
-
getImports: (tree: Array<Schema>) => Array<Import>;
|
|
97
|
+
}) => KubbFile.File<FileMeta>;
|
|
98
|
+
getImports: (tree: Array<Schema>) => Array<KubbFile.Import>;
|
|
119
99
|
};
|
|
120
100
|
/**
|
|
121
101
|
* `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.
|
|
122
102
|
*/
|
|
123
103
|
declare function useSchemaManager(): UseSchemaManagerResult;
|
|
124
104
|
//#endregion
|
|
125
|
-
export { type SchemaNames, useOas, useOperation, useOperationManager,
|
|
105
|
+
export { type SchemaNames, useOas, useOperation, useOperationManager, useSchema, useSchemaManager };
|
|
126
106
|
//# sourceMappingURL=hooks.d.cts.map
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as SchemaContextProps } from "./Schema-
|
|
1
|
+
import { M as Plugin, N as ResolveNameParams, P as Oas, R as Operation, k as FileMetaBase, y as OperationSchemas } from "./OperationGenerator-CRZpkIpZ.js";
|
|
2
|
+
import { t as Schema } from "./SchemaMapper-CtfTw3hq.js";
|
|
3
|
+
import { n as SchemaContextProps } from "./Schema-DBvtiLS7.js";
|
|
4
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
4
5
|
|
|
5
6
|
//#region src/hooks/useOas.d.ts
|
|
6
7
|
declare function useOas(): Oas;
|
|
@@ -43,12 +44,12 @@ type UseOperationManagerResult = {
|
|
|
43
44
|
prefix?: string;
|
|
44
45
|
suffix?: string;
|
|
45
46
|
pluginKey?: Plugin['key'];
|
|
46
|
-
extname?: Extname;
|
|
47
|
+
extname?: KubbFile.Extname;
|
|
47
48
|
group?: {
|
|
48
49
|
tag?: string;
|
|
49
50
|
path?: string;
|
|
50
51
|
};
|
|
51
|
-
}) => File<FileMeta$1>;
|
|
52
|
+
}) => KubbFile.File<FileMeta$1>;
|
|
52
53
|
groupSchemasByName: (operation: Operation, params: {
|
|
53
54
|
pluginKey?: Plugin['key'];
|
|
54
55
|
type: ResolveNameParams['type'];
|
|
@@ -64,27 +65,6 @@ type UseOperationManagerResult = {
|
|
|
64
65
|
*/
|
|
65
66
|
declare function useOperationManager(): UseOperationManagerResult;
|
|
66
67
|
//#endregion
|
|
67
|
-
//#region src/hooks/useOperations.d.ts
|
|
68
|
-
type UseOperationsProps = {
|
|
69
|
-
/**
|
|
70
|
-
* Filter based on path
|
|
71
|
-
* Weight: 2
|
|
72
|
-
*/
|
|
73
|
-
path?: string;
|
|
74
|
-
/**
|
|
75
|
-
* Filter based on method
|
|
76
|
-
* Weight: 1
|
|
77
|
-
*/
|
|
78
|
-
method?: HttpMethod;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* `useOperations` will return all the Operations
|
|
82
|
-
*/
|
|
83
|
-
declare function useOperations({
|
|
84
|
-
method,
|
|
85
|
-
path
|
|
86
|
-
}?: UseOperationsProps): Operation[];
|
|
87
|
-
//#endregion
|
|
88
68
|
//#region src/hooks/useSchema.d.ts
|
|
89
69
|
type UseSchemaResult = SchemaContextProps;
|
|
90
70
|
/**
|
|
@@ -108,19 +88,19 @@ type UseSchemaManagerResult = {
|
|
|
108
88
|
}) => string;
|
|
109
89
|
getFile: (name: string, params?: {
|
|
110
90
|
pluginKey?: Plugin['key'];
|
|
111
|
-
mode?: Mode;
|
|
112
|
-
extname?: Extname;
|
|
91
|
+
mode?: KubbFile.Mode;
|
|
92
|
+
extname?: KubbFile.Extname;
|
|
113
93
|
group?: {
|
|
114
94
|
tag?: string;
|
|
115
95
|
path?: string;
|
|
116
96
|
};
|
|
117
|
-
}) => File<FileMeta>;
|
|
118
|
-
getImports: (tree: Array<Schema>) => Array<Import>;
|
|
97
|
+
}) => KubbFile.File<FileMeta>;
|
|
98
|
+
getImports: (tree: Array<Schema>) => Array<KubbFile.Import>;
|
|
119
99
|
};
|
|
120
100
|
/**
|
|
121
101
|
* `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.
|
|
122
102
|
*/
|
|
123
103
|
declare function useSchemaManager(): UseSchemaManagerResult;
|
|
124
104
|
//#endregion
|
|
125
|
-
export { type SchemaNames, useOas, useOperation, useOperationManager,
|
|
105
|
+
export { type SchemaNames, useOas, useOperation, useOperationManager, useSchema, useSchemaManager };
|
|
126
106
|
//# sourceMappingURL=hooks.d.ts.map
|
package/dist/hooks.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
5
|
-
import
|
|
1
|
+
import { n as Schema, r as Operation, t as Oas } from "./Oas-CHC1IC5D.js";
|
|
2
|
+
import "./utils-DaV25sy8.js";
|
|
3
|
+
import { t as SchemaGenerator } from "./SchemaGenerator-b7XixzRv.js";
|
|
4
|
+
import { n as schemaKeywords } from "./SchemaMapper-Cx4X1al6.js";
|
|
5
|
+
import "./getSchemas-Bdg6n9Qk.js";
|
|
6
|
+
import { useApp, useContext } from "@kubb/react-fabric";
|
|
6
7
|
import { usePlugin, usePluginManager } from "@kubb/core/hooks";
|
|
7
8
|
|
|
8
9
|
//#region src/hooks/useOas.ts
|
|
9
10
|
function useOas() {
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
return oas;
|
|
11
|
+
const { meta } = useApp();
|
|
12
|
+
return meta.oas;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
@@ -146,20 +146,6 @@ function useOperationManager() {
|
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
//#endregion
|
|
150
|
-
//#region src/hooks/useOperations.ts
|
|
151
|
-
/**
|
|
152
|
-
* `useOperations` will return all the Operations
|
|
153
|
-
*/
|
|
154
|
-
function useOperations({ method, path } = {}) {
|
|
155
|
-
const { operations } = useContext(Oas.Context);
|
|
156
|
-
if (!operations) throw new Error("Operations is not defined");
|
|
157
|
-
let items = operations;
|
|
158
|
-
if (path) items = items.filter((item) => item.path === path);
|
|
159
|
-
if (method) items = items.filter((item) => item.method === method);
|
|
160
|
-
return items;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
149
|
//#endregion
|
|
164
150
|
//#region src/hooks/useSchema.ts
|
|
165
151
|
/**
|
|
@@ -225,5 +211,5 @@ function useSchemaManager() {
|
|
|
225
211
|
}
|
|
226
212
|
|
|
227
213
|
//#endregion
|
|
228
|
-
export { useOas, useOperation, useOperationManager,
|
|
214
|
+
export { useOas, useOperation, useOperationManager, useSchema, useSchemaManager };
|
|
229
215
|
//# sourceMappingURL=hooks.js.map
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":["getName: UseOperationManagerResult['getName']","getGroup: UseOperationManagerResult['getGroup']","getSchemas: UseOperationManagerResult['getSchemas']","getFile: UseOperationManagerResult['getFile']","groupSchemasByName: UseOperationManagerResult['groupSchemasByName']","getName: UseSchemaManagerResult['getName']","getFile: UseSchemaManagerResult['getFile']","getImports: UseSchemaManagerResult['getImports']"],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts","../src/hooks/useSchema.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport { useContext } from '@kubb/react'\nimport { Oas } from '../components/Oas.tsx'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\n const { generator } = useContext(Oas.Context)\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {\n return {\n tag: operation.getTags().at(0)?.name,\n path: operation.path,\n }\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\n const group = getGroup(operation)\n\n const file = pluginManager.getFile({\n name,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n const responses = (schemas.responses || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas,\n groupSchemasByName,\n getGroup,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n","import { useContext } from '@kubb/react'\n\nimport { Schema } from '../components/Schema.tsx'\n\nimport type { SchemaContextProps } from '../components/Schema.tsx'\n\ntype UseSchemaResult = SchemaContextProps\n\n/**\n * `useSchema` will return the current `schema properties`\n */\nexport function useSchema(): UseSchemaResult {\n const props = useContext(Schema.Context)\n\n return props as UseSchemaResult\n}\n","import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport { type Schema, schemaKeywords } from '../SchemaMapper'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginKey?: Plugin['key']\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n getImports: (tree: Array<Schema>) => Array<KubbFile.Import>\n}\n\n/**\n * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n const getImports: UseSchemaManagerResult['getImports'] = (tree) => {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n }\n\n return {\n getName,\n getFile,\n getImports,\n }\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,SAAkB;CAChC,MAAM,EAAE,QAAQ,WAAW,IAAI,QAAQ;AAEvC,KAAI,CAAC,IACH,OAAM,IAAI,MAAM,qBAAqB;AAGvC,QAAO;;;;;;;;ACJT,SAAgB,eAA8B;CAC5C,MAAM,EAAE,cAAc,WAAW,UAAU,QAAQ;AAEnD,KAAI,CAAC,UACH,OAAM,IAAI,MAAM,2BAA2B;AAG7C,QAAO;;;;;;;;ACiDT,SAAgB,sBAAiD;CAC/D,MAAM,SAAS,WAAW;CAC1B,MAAM,gBAAgB,kBAAkB;CACxC,MAAM,EAAE,cAAc,WAAW,IAAI,QAAQ;CAE7C,MAAMA,WAAiD,WAAW,EAAE,SAAS,IAAI,SAAS,IAAI,YAAY,OAAO,KAAK,WAAW;AAC/H,SAAO,cAAc,YAAY;GAC/B,MAAM,GAAG,OAAO,GAAG,UAAU,gBAAgB,CAAC,GAAG;GACjD;GACA;GACD,CAAC;;CAGJ,MAAMC,YAAmD,cAAc;AACrE,SAAO;GACL,KAAK,UAAU,SAAS,CAAC,GAAG,EAAE,EAAE;GAChC,MAAM,UAAU;GACjB;;CAGH,MAAMC,cAAuD,W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GACjC,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAW;IAAO;GAC5C,CAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;;CAGH,MAAMC,cAAoD,SAAS;AAGjE,SAFa,gBAAgB,WAAW,MAAM,eAAe,IAAI,EAG7D,KAAK,SAAS;AACd,OAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAChC;AAGF,UAAO;IACL,MAAM,CAAC,KAAK,KAAK,KAAK;IACtB,MAAM,KAAK,KAAK;IACjB;IACD,CACD,OAAO,QAAQ;;AAGpB,QAAO;EACL;EACA;EACA;EACD"}
|
|
1
|
+
{"version":3,"file":"hooks.js","names":["getName: UseOperationManagerResult['getName']","getGroup: UseOperationManagerResult['getGroup']","getSchemas: UseOperationManagerResult['getSchemas']","getFile: UseOperationManagerResult['getFile']","groupSchemasByName: UseOperationManagerResult['groupSchemasByName']","getName: UseSchemaManagerResult['getName']","getFile: UseSchemaManagerResult['getFile']","getImports: UseSchemaManagerResult['getImports']"],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useSchema.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useOas(): Oas {\n const { meta } = useApp<{ oas: Oas }>()\n\n return meta.oas\n}\n","import { useContext } from '@kubb/react-fabric'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport { useContext } from '@kubb/react-fabric'\nimport { Oas } from '../components/Oas.tsx'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\n const { generator } = useContext(Oas.Context)\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {\n return {\n tag: operation.getTags().at(0)?.name,\n path: operation.path,\n }\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\n const group = getGroup(operation)\n\n const file = pluginManager.getFile({\n name,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n const responses = (schemas.responses || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas,\n groupSchemasByName,\n getGroup,\n }\n}\n","import { useContext } from '@kubb/react-fabric'\n\nimport { Schema } from '../components/Schema.tsx'\n\nimport type { SchemaContextProps } from '../components/Schema.tsx'\n\ntype UseSchemaResult = SchemaContextProps\n\n/**\n * `useSchema` will return the current `schema properties`\n */\nexport function useSchema(): UseSchemaResult {\n const props = useContext(Schema.Context)\n\n return props as UseSchemaResult\n}\n","import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport { type Schema, schemaKeywords } from '../SchemaMapper'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginKey?: Plugin['key']\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n getImports: (tree: Array<Schema>) => Array<KubbFile.Import>\n}\n\n/**\n * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n const getImports: UseSchemaManagerResult['getImports'] = (tree) => {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n }\n\n return {\n getName,\n getFile,\n getImports,\n }\n}\n"],"mappings":";;;;;;;;;AAIA,SAAgB,SAAc;CAC5B,MAAM,EAAE,SAAS,QAAsB;AAEvC,QAAO,KAAK;;;;;;;;ACEd,SAAgB,eAA8B;CAC5C,MAAM,EAAE,cAAc,WAAW,UAAU,QAAQ;AAEnD,KAAI,CAAC,UACH,OAAM,IAAI,MAAM,2BAA2B;AAG7C,QAAO;;;;;;;;ACiDT,SAAgB,sBAAiD;CAC/D,MAAM,SAAS,WAAW;CAC1B,MAAM,gBAAgB,kBAAkB;CACxC,MAAM,EAAE,cAAc,WAAW,IAAI,QAAQ;CAE7C,MAAMA,WAAiD,WAAW,EAAE,SAAS,IAAI,SAAS,IAAI,YAAY,OAAO,KAAK,WAAW;AAC/H,SAAO,cAAc,YAAY;GAC/B,MAAM,GAAG,OAAO,GAAG,UAAU,gBAAgB,CAAC,GAAG;GACjD;GACA;GACD,CAAC;;CAGJ,MAAMC,YAAmD,cAAc;AACrE,SAAO;GACL,KAAK,UAAU,SAAS,CAAC,GAAG,EAAE,EAAE;GAChC,MAAM,UAAU;GACjB;;CAGH,MAAMC,cAAuD,WAAW,WAAW;AACjF,MAAI,CAAC,UACH,OAAM,IAAI,MAAM,6BAA6B;AAG/C,SAAO,UAAU,WAAW,WAAW,EACrC,cAAc,SACZ,cAAc,YAAY;GACxB;GACA,WAAW,QAAQ;GACnB,MAAM,QAAQ;GACf,CAAC,EACL,CAAC;;CAGJ,MAAMC,WAAiD,WAAW,EAAE,QAAQ,QAAQ,YAAY,OAAO,KAAK,UAAU,UAAU,EAAE,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
-
require('./
|
|
6
|
-
const
|
|
7
|
-
require('./
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
__kubb_core = require_chunk.__toESM(__kubb_core);
|
|
2
|
+
const require_generators = require('./generators-B27La9Vd.cjs');
|
|
3
|
+
require('./getFooter-CwjCW4h5.cjs');
|
|
4
|
+
require('./Oas-CQrRP_NH.cjs');
|
|
5
|
+
const require_utils = require('./utils-DYf-j63H.cjs');
|
|
6
|
+
const require_SchemaGenerator = require('./SchemaGenerator-DWj6buY0.cjs');
|
|
7
|
+
const require_SchemaMapper = require('./SchemaMapper-DoL-a6qq.cjs');
|
|
8
|
+
require('./getSchemas-DY8s2CSl.cjs');
|
|
9
|
+
const require_parseFromConfig = require('./parseFromConfig-RR31a98-.cjs');
|
|
11
10
|
let __kubb_core_transformers = require("@kubb/core/transformers");
|
|
12
11
|
__kubb_core_transformers = require_chunk.__toESM(__kubb_core_transformers);
|
|
13
12
|
let node_path = require("node:path");
|
|
14
13
|
node_path = require_chunk.__toESM(node_path);
|
|
14
|
+
let __kubb_core = require("@kubb/core");
|
|
15
|
+
__kubb_core = require_chunk.__toESM(__kubb_core);
|
|
15
16
|
|
|
16
17
|
//#region src/OperationGenerator.ts
|
|
17
18
|
var OperationGenerator = class extends __kubb_core.BaseGenerator {
|
|
@@ -152,6 +153,18 @@ var OperationGenerator = class extends __kubb_core.BaseGenerator {
|
|
|
152
153
|
const writeTasks = generators.map((generator) => generatorLimit(async () => {
|
|
153
154
|
const operationTasks = operations.map(({ operation, method }) => operationLimit(async () => {
|
|
154
155
|
const options = this.#getOptions(operation, method);
|
|
156
|
+
if (generator.type === "react") {
|
|
157
|
+
await require_utils.buildOperation(operation, {
|
|
158
|
+
fabric: this.context.fabric,
|
|
159
|
+
generator,
|
|
160
|
+
instance: this,
|
|
161
|
+
options: {
|
|
162
|
+
...this.options,
|
|
163
|
+
...options
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
155
168
|
return await generator.operation?.({
|
|
156
169
|
instance: this,
|
|
157
170
|
operation,
|
|
@@ -162,6 +175,15 @@ var OperationGenerator = class extends __kubb_core.BaseGenerator {
|
|
|
162
175
|
}) ?? [];
|
|
163
176
|
}));
|
|
164
177
|
const opResultsFlat = (await Promise.all(operationTasks)).flat();
|
|
178
|
+
if (generator.type === "react") {
|
|
179
|
+
await require_utils.buildOperations(operations.map((op) => op.operation), {
|
|
180
|
+
fabric: this.context.fabric,
|
|
181
|
+
generator,
|
|
182
|
+
instance: this,
|
|
183
|
+
options: this.options
|
|
184
|
+
});
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
165
187
|
const operationsResult = await generator.operations?.({
|
|
166
188
|
instance: this,
|
|
167
189
|
operations: operations.map((op) => op.operation),
|
|
@@ -247,6 +269,7 @@ const pluginOas = (0, __kubb_core.createPlugin)((options) => {
|
|
|
247
269
|
transformers: {},
|
|
248
270
|
...this.plugin.options
|
|
249
271
|
}, {
|
|
272
|
+
fabric: this.fabric,
|
|
250
273
|
oas: oas$1,
|
|
251
274
|
pluginManager: this.pluginManager,
|
|
252
275
|
plugin: this.plugin,
|
|
@@ -258,6 +281,7 @@ const pluginOas = (0, __kubb_core.createPlugin)((options) => {
|
|
|
258
281
|
}).build(...generators);
|
|
259
282
|
await this.addFile(...schemaFiles);
|
|
260
283
|
const operationFiles = await new OperationGenerator(this.plugin.options, {
|
|
284
|
+
fabric: this.fabric,
|
|
261
285
|
oas: oas$1,
|
|
262
286
|
pluginManager: this.pluginManager,
|
|
263
287
|
plugin: this.plugin,
|
|
@@ -275,9 +299,13 @@ const pluginOas = (0, __kubb_core.createPlugin)((options) => {
|
|
|
275
299
|
//#endregion
|
|
276
300
|
exports.OperationGenerator = OperationGenerator;
|
|
277
301
|
exports.SchemaGenerator = require_SchemaGenerator.SchemaGenerator;
|
|
302
|
+
exports.buildOperation = require_utils.buildOperation;
|
|
303
|
+
exports.buildOperations = require_utils.buildOperations;
|
|
304
|
+
exports.buildSchema = require_utils.buildSchema;
|
|
278
305
|
exports.createGenerator = require_generators.createGenerator;
|
|
279
306
|
exports.createReactGenerator = require_generators.createReactGenerator;
|
|
280
307
|
exports.isKeyword = require_SchemaMapper.isKeyword;
|
|
308
|
+
exports.jsonGenerator = require_generators.jsonGenerator;
|
|
281
309
|
exports.pluginOas = pluginOas;
|
|
282
310
|
exports.pluginOasName = pluginOasName;
|
|
283
311
|
exports.schemaKeywords = require_SchemaMapper.schemaKeywords;
|