@kubb/plugin-oas 3.0.0-alpha.0 → 3.0.0-alpha.10

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.
Files changed (73) hide show
  1. package/dist/OperationGenerator-By5WOmWB.d.ts +165 -0
  2. package/dist/OperationGenerator-Gd1X7wUz.d.cts +165 -0
  3. package/dist/{Schema-DefwBJMc.d.ts → Schema-B1vcPGiK.d.ts} +3 -5
  4. package/dist/{Schema-an5hOrjZ.d.cts → Schema-DoSFh7Qd.d.cts} +3 -5
  5. package/dist/{SchemaMapper-CsBQ6eEx.d.cts → SchemaMapper-sGcY1xL5.d.cts} +1 -2
  6. package/dist/{SchemaMapper-CsBQ6eEx.d.ts → SchemaMapper-sGcY1xL5.d.ts} +1 -2
  7. package/dist/chunk-75BIOXB7.cjs +7 -0
  8. package/dist/chunk-75BIOXB7.cjs.map +1 -0
  9. package/dist/{chunk-UKUEVTRB.cjs → chunk-IAUV3UKH.cjs} +735 -35
  10. package/dist/chunk-IAUV3UKH.cjs.map +1 -0
  11. package/dist/{chunk-QSM6A5QX.js → chunk-M347763D.js} +714 -14
  12. package/dist/chunk-M347763D.js.map +1 -0
  13. package/dist/{chunk-GUPCIAYT.js → chunk-N7EEVJA6.js} +3 -3
  14. package/dist/{chunk-J7IF3KA3.cjs → chunk-NU4F7G47.cjs} +4 -16
  15. package/dist/chunk-NU4F7G47.cjs.map +1 -0
  16. package/dist/{chunk-3UN2S6P2.cjs → chunk-O76YQFZB.cjs} +3 -3
  17. package/dist/{chunk-3UN2S6P2.cjs.map → chunk-O76YQFZB.cjs.map} +1 -1
  18. package/dist/chunk-SQ64ESS4.js +7 -0
  19. package/dist/chunk-SQ64ESS4.js.map +1 -0
  20. package/dist/{chunk-Y272OQMW.js → chunk-SZDO532A.js} +3 -15
  21. package/dist/chunk-SZDO532A.js.map +1 -0
  22. package/dist/components.cjs +4 -9
  23. package/dist/components.cjs.map +1 -1
  24. package/dist/components.d.cts +13 -7
  25. package/dist/components.d.ts +13 -7
  26. package/dist/components.js +3 -8
  27. package/dist/components.js.map +1 -1
  28. package/dist/hooks.cjs +12 -13
  29. package/dist/hooks.cjs.map +1 -1
  30. package/dist/hooks.d.cts +4 -4
  31. package/dist/hooks.d.ts +4 -4
  32. package/dist/hooks.js +2 -3
  33. package/dist/hooks.js.map +1 -1
  34. package/dist/index.cjs +282 -231
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +8 -77
  37. package/dist/index.d.ts +8 -77
  38. package/dist/index.js +274 -223
  39. package/dist/index.js.map +1 -1
  40. package/dist/{types-BP45TdiW.d.cts → types-CZTUCaE5.d.cts} +3 -6
  41. package/dist/{types-BP45TdiW.d.ts → types-CZTUCaE5.d.ts} +3 -6
  42. package/dist/utils.cjs +12 -54
  43. package/dist/utils.cjs.map +1 -1
  44. package/dist/utils.d.cts +7 -33
  45. package/dist/utils.d.ts +7 -33
  46. package/dist/utils.js +6 -48
  47. package/dist/utils.js.map +1 -1
  48. package/package.json +12 -11
  49. package/src/OperationGenerator.ts +68 -32
  50. package/src/SchemaGenerator.ts +32 -15
  51. package/src/SchemaMapper.ts +1 -1
  52. package/src/components/Oas.tsx +9 -3
  53. package/src/components/Operation.tsx +1 -1
  54. package/src/components/Schema.tsx +29 -31
  55. package/src/generator.tsx +125 -0
  56. package/src/hooks/useOperationManager.ts +1 -0
  57. package/src/index.ts +3 -9
  58. package/src/plugin.ts +25 -38
  59. package/src/types.ts +2 -6
  60. package/src/utils/getParams.ts +1 -1
  61. package/src/utils/index.ts +2 -1
  62. package/dist/OperationGenerator-B0RLFu4P.d.ts +0 -60
  63. package/dist/OperationGenerator-CrCcKl3S.d.cts +0 -60
  64. package/dist/chunk-J7IF3KA3.cjs.map +0 -1
  65. package/dist/chunk-K4GEQ3C2.cjs +0 -698
  66. package/dist/chunk-K4GEQ3C2.cjs.map +0 -1
  67. package/dist/chunk-QSM6A5QX.js.map +0 -1
  68. package/dist/chunk-UKUEVTRB.cjs.map +0 -1
  69. package/dist/chunk-Y272OQMW.js.map +0 -1
  70. package/dist/chunk-ZZ7ZC4TT.js +0 -698
  71. package/dist/chunk-ZZ7ZC4TT.js.map +0 -1
  72. package/src/utils/getGroupedByTagFiles.ts +0 -82
  73. /package/dist/{chunk-GUPCIAYT.js.map → chunk-N7EEVJA6.js.map} +0 -0
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  init_esm_shims
3
- } from "./chunk-Y272OQMW.js";
3
+ } from "./chunk-SZDO532A.js";
4
4
 
5
5
  // src/utils/parseFromConfig.ts
6
6
  init_esm_shims();
7
- import { resolve } from "path";
7
+ import { resolve } from "node:path";
8
8
  import { URLPath } from "@kubb/core/utils";
9
9
  import { parse } from "@kubb/oas/parser";
10
10
  import { Oas } from "@kubb/oas";
@@ -32,4 +32,4 @@ function parseFromConfig(config, options = {}, oasClass = Oas) {
32
32
  export {
33
33
  parseFromConfig
34
34
  };
35
- //# sourceMappingURL=chunk-GUPCIAYT.js.map
35
+ //# sourceMappingURL=chunk-N7EEVJA6.js.map
@@ -4,9 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __typeError = (msg) => {
8
- throw TypeError(msg);
9
- };
10
7
  var __esm = (fn, res) => function __init() {
11
8
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
12
9
  };
@@ -29,15 +26,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
26
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
27
  mod
31
28
  ));
32
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
33
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
34
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
35
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
37
29
 
38
- // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.5_@types+node@20.14.15__jiti@1.21.6_postcss@8.4.40_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js
30
+ // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js
39
31
  var init_cjs_shims = __esm({
40
- "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.5_@types+node@20.14.15__jiti@1.21.6_postcss@8.4.40_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js"() {
32
+ "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js"() {
41
33
  "use strict";
42
34
  }
43
35
  });
@@ -93,9 +85,5 @@ function getSchemaFactory(oas) {
93
85
 
94
86
 
95
87
 
96
-
97
-
98
-
99
-
100
- exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet; exports.__privateMethod = __privateMethod; exports.init_cjs_shims = init_cjs_shims; exports.getSchemas = getSchemas; exports.getSchemaFactory = getSchemaFactory;
101
- //# sourceMappingURL=chunk-J7IF3KA3.cjs.map
88
+ exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.init_cjs_shims = init_cjs_shims; exports.getSchemas = getSchemas; exports.getSchemaFactory = getSchemaFactory;
89
+ //# sourceMappingURL=chunk-NU4F7G47.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-NU4F7G47.cjs","../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js","../src/utils/getSchemas.ts","../src/utils/getSchemaFactory.ts"],"names":[],"mappings":"AAAA,ilBAAI,SAAS,EAAE,MAAM,CAAC,MAAM;AAC5B,IAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,iBAAiB,EAAE,MAAM,CAAC,wBAAwB;AACtD,IAAI,kBAAkB,EAAE,MAAM,CAAC,mBAAmB;AAClD,IAAI,aAAa,EAAE,MAAM,CAAC,cAAc;AACxC,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc;AAClD,IAAI,MAAM,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,SAAS,MAAM,CAAC,EAAE;AAC3C,EAAE,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG;AACrE,CAAC;AACD,IAAI,WAAW,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,SAAS,SAAS,CAAC,EAAE;AACnD,EAAE,OAAO,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,OA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,CAAE,OAAA,CAAQ,CAAC,CAAC,IAAA,EAAM,OAAO,CAAA,EAAA,GAA4C;AAC/F,MAAA,GAAA,CAAI,OAAA,CAAQ,QAAA,GAAW,CAAC,OAAA,CAAQ,IAAI,CAAA,EAAG;AACrC,QAAA,MAAM,iBAAA,EAAmB,MAAA,CAAO,IAAA,CAAK,OAAA,CAAQ,OAAO,CAAA,CAAE,CAAC,EAAA,GAAK,kBAAA;AAC5D,QAAA,OAAA,CAAQ,IAAI,EAAA,kBAAI,OAAA,qBAAQ,OAAA,4BAAA,CAAU,YAAA,GAAe,gBAAgB,CAAA,6BAAG,QAAA;AAAA,MACtE;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,OAAA;AACT;AFuBA;AACA;AGpEA,cAAA,CAAA,CAAA;AAAA,gCAAsC;AAuB/B,SAAS,gBAAA,CAAmD,GAAA,EAA6D;AAC9H,EAAA,OAAO,CAAC,MAAA,EAAA,GAA0B;AAChC,IAAA,MAAM,QAAA,EAAU,wCAAA,GAAsB,CAAI,GAAG,EAAA,EAAI,MAAA,EAAQ,KAAA;AAEzD,IAAA,OAAO;AAAA,MACL,MAAA;AAAA,MACA;AAAA,IACF,CAAA;AAAA,EACF,CAAA;AACF;AHgDA;AACA;AACE;AACA;AACA;AACA;AACA;AACF,kLAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-NU4F7G47.cjs","sourcesContent":[null,"// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\nexport type 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","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 schema?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schema?: (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\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 schema,\n version,\n } as SchemaResult<TWithRef>\n }\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunkJ7IF3KA3cjs = require('./chunk-J7IF3KA3.cjs');
3
+ var _chunkNU4F7G47cjs = require('./chunk-NU4F7G47.cjs');
4
4
 
5
5
  // src/utils/parseFromConfig.ts
6
- _chunkJ7IF3KA3cjs.init_cjs_shims.call(void 0, );
6
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
7
7
  var _path = require('path');
8
8
  var _utils = require('@kubb/core/utils');
9
9
  var _parser = require('@kubb/oas/parser');
@@ -32,4 +32,4 @@ function parseFromConfig(config, options = {}, oasClass = _oas.Oas) {
32
32
 
33
33
 
34
34
  exports.parseFromConfig = parseFromConfig;
35
- //# sourceMappingURL=chunk-3UN2S6P2.cjs.map
35
+ //# sourceMappingURL=chunk-O76YQFZB.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-3UN2S6P2.cjs","../src/utils/parseFromConfig.ts"],"names":["api"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,8CAAA,CAAA;AAAA,4BAAwB;AAExB,yCAAwB;AAExB,0CAA0C;AAG1C,gCAAmC;AACnC,mFAAiB;AAEV,SAAS,eAAA,CAAgB,MAAA,EAAgB,QAAA,EAAyB,CAAC,CAAA,EAAG,SAAA,EAAuB,QAAA,EAAmB;AACrH,EAAA,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,KAAA,EAAO;AAC1B,IAAA,GAAA,CAAI,OAAO,MAAA,CAAO,KAAA,CAAM,KAAA,IAAS,QAAA,EAAU;AACzC,MAAA,MAAMA,KAAAA,EAA4B,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,KAAA,CAAM,IAAI,CAAC,CAAA;AAC9E,MAAA,OAAO,2BAAA,IAAMA,EAAK,OAAA,EAAS,QAAQ,CAAA;AAAA,IACrC;AAEA,IAAA,IAAI;AACF,MAAA,MAAMA,KAAAA,EAAc,cAAA,CAAK,KAAA,CAAM,MAAA,CAAO,KAAA,CAAM,IAAc,CAAA;AAE1D,MAAA,OAAO,2BAAA,IAAMA,EAAK,OAAA,EAAS,QAAQ,CAAA;AAAA,IACrC,EAAA,MAAA,CAAS,CAAA,EAAG;AAAA,IAEZ;AAEA,IAAA,MAAM,IAAA,EAA4B,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,KAAA,CAAM,IAAI,CAAC,CAAA;AAE9E,IAAA,OAAO,2BAAA,GAAM,EAAK,OAAA,EAAS,QAAQ,CAAA;AAAA,EACrC;AAEA,EAAA,GAAA,CAAI,IAAI,mBAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,IAAI,CAAA,CAAE,KAAA,EAAO;AACxC,IAAA,OAAO,2BAAA,MAAM,CAAO,KAAA,CAAM,IAAA,EAAM,OAAA,EAAS,QAAQ,CAAA;AAAA,EACnD;AAEA,EAAA,OAAO,2BAAA,2BAAM,MAAQ,CAAO,IAAA,EAAM,MAAA,CAAO,KAAA,CAAM,IAAI,CAAA,EAAG,OAAA,EAAS,QAAQ,CAAA;AACzE;ADLA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-3UN2S6P2.cjs","sourcesContent":[null,"import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { type FormatOptions, parse } from '@kubb/oas/parser'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, options, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, options, oasClass)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, options, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, options, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), options, oasClass)\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-O76YQFZB.cjs","../src/utils/parseFromConfig.ts"],"names":["api"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,8CAAA,CAAA;AAAA,4BAAwB;AAExB,yCAAwB;AAExB,0CAA0C;AAG1C,gCAAmC;AACnC,mFAAiB;AAEV,SAAS,eAAA,CAAgB,MAAA,EAAgB,QAAA,EAAyB,CAAC,CAAA,EAAG,SAAA,EAAuB,QAAA,EAAmB;AACrH,EAAA,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,KAAA,EAAO;AAC1B,IAAA,GAAA,CAAI,OAAO,MAAA,CAAO,KAAA,CAAM,KAAA,IAAS,QAAA,EAAU;AACzC,MAAA,MAAMA,KAAAA,EAA4B,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,KAAA,CAAM,IAAI,CAAC,CAAA;AAC9E,MAAA,OAAO,2BAAA,IAAMA,EAAK,OAAA,EAAS,QAAQ,CAAA;AAAA,IACrC;AAEA,IAAA,IAAI;AACF,MAAA,MAAMA,KAAAA,EAAc,cAAA,CAAK,KAAA,CAAM,MAAA,CAAO,KAAA,CAAM,IAAc,CAAA;AAE1D,MAAA,OAAO,2BAAA,IAAMA,EAAK,OAAA,EAAS,QAAQ,CAAA;AAAA,IACrC,EAAA,MAAA,CAAS,CAAA,EAAG;AAAA,IAEZ;AAEA,IAAA,MAAM,IAAA,EAA4B,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,KAAA,CAAM,IAAI,CAAC,CAAA;AAE9E,IAAA,OAAO,2BAAA,GAAM,EAAK,OAAA,EAAS,QAAQ,CAAA;AAAA,EACrC;AAEA,EAAA,GAAA,CAAI,IAAI,mBAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,IAAI,CAAA,CAAE,KAAA,EAAO;AACxC,IAAA,OAAO,2BAAA,MAAM,CAAO,KAAA,CAAM,IAAA,EAAM,OAAA,EAAS,QAAQ,CAAA;AAAA,EACnD;AAEA,EAAA,OAAO,2BAAA,2BAAM,MAAQ,CAAO,IAAA,EAAM,MAAA,CAAO,KAAA,CAAM,IAAI,CAAA,EAAG,OAAA,EAAS,QAAQ,CAAA;AACzE;ADLA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-O76YQFZB.cjs","sourcesContent":[null,"import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { type FormatOptions, parse } from '@kubb/oas/parser'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, options, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, options, oasClass)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, options, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, options, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), options, oasClass)\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import {
2
+ init_esm_shims
3
+ } from "./chunk-SZDO532A.js";
4
+
5
+ // src/components/index.ts
6
+ init_esm_shims();
7
+ //# sourceMappingURL=chunk-SQ64ESS4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/index.ts"],"sourcesContent":["export { Oas } from './Oas.tsx'\nexport { Operation } from './Operation.tsx'\nexport { Schema } from './Schema.tsx'\n"],"mappings":";;;;;AAAA;","names":[]}
@@ -4,9 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __typeError = (msg) => {
8
- throw TypeError(msg);
9
- };
10
7
  var __esm = (fn, res) => function __init() {
11
8
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
12
9
  };
@@ -29,15 +26,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
26
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
27
  mod
31
28
  ));
32
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
33
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
34
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
35
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
37
29
 
38
- // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.5_@types+node@20.14.15__jiti@1.21.6_postcss@8.4.40_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js
30
+ // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js
39
31
  var init_esm_shims = __esm({
40
- "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.5_@types+node@20.14.15__jiti@1.21.6_postcss@8.4.40_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js"() {
32
+ "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js"() {
41
33
  "use strict";
42
34
  }
43
35
  });
@@ -90,12 +82,8 @@ function getSchemaFactory(oas) {
90
82
  export {
91
83
  __commonJS,
92
84
  __toESM,
93
- __privateGet,
94
- __privateAdd,
95
- __privateSet,
96
- __privateMethod,
97
85
  init_esm_shims,
98
86
  getSchemas,
99
87
  getSchemaFactory
100
88
  };
101
- //# sourceMappingURL=chunk-Y272OQMW.js.map
89
+ //# sourceMappingURL=chunk-SZDO532A.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js","../src/utils/getSchemas.ts","../src/utils/getSchemaFactory.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\nexport type 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","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 schema?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schema?: (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\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 schema,\n version,\n } as SchemaResult<TWithRef>\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAUO,SAAS,WAAW,EAAE,KAAK,aAAa,WAAW,CAAC,WAAW,iBAAiB,WAAW,EAAE,GAA2D;AAC7J,QAAM,aAAa,IAAI,cAAc,EAAE;AAEvC,MAAI,UAAiD,CAAC;AAEtD,MAAI,SAAS,SAAS,SAAS,GAAG;AAChC,cAAU;AAAA,MACR,GAAG;AAAA,MACH,GAAK,YAAY,WAAqD,CAAC;AAAA,IACzE;AAAA,EACF;AAEA,QAAM,gBAAgB,YAAY,iBAAiB,CAAC;AACpD,MAAI,SAAS,SAAS,WAAW,GAAG;AAClC,UAAM,YAAY,YAAY,aAAa,CAAC;AAE5C,WAAO,QAAQ,SAAS,EAAE,QAAQ,CAAC,CAAC,MAAM,QAAQ,MAAyC;AACzF,UAAI,SAAS,WAAW,CAAC,QAAQ,IAAI,GAAG;AACtC,cAAM,mBAAmB,OAAO,KAAK,SAAS,OAAO,EAAE,CAAC,KAAK;AAC7D,gBAAQ,IAAI,IAAI,SAAS,UAAU,eAAe,gBAAgB,GAAG;AAAA,MACvE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,MAAI,SAAS,SAAS,eAAe,GAAG;AACtC,WAAO,QAAQ,aAAa,EAAE,QAAQ,CAAC,CAAC,MAAM,OAAO,MAA4C;AAC/F,UAAI,QAAQ,WAAW,CAAC,QAAQ,IAAI,GAAG;AACrC,cAAM,mBAAmB,OAAO,KAAK,QAAQ,OAAO,EAAE,CAAC,KAAK;AAC5D,gBAAQ,IAAI,IAAI,QAAQ,UAAU,eAAe,gBAAgB,GAAG;AAAA,MACtE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;;;AC5CA;AAAA,SAAS,6BAA6B;AAuB/B,SAAS,iBAAmD,KAA6D;AAC9H,SAAO,CAAC,WAA0B;AAChC,UAAM,UAAU,sBAAsB,IAAI,GAAG,IAAI,QAAQ;AAEzD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,18 +1,13 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-75BIOXB7.cjs');
2
2
 
3
3
 
4
4
 
5
- var _chunkUKUEVTRBcjs = require('./chunk-UKUEVTRB.cjs');
6
- require('./chunk-K4GEQ3C2.cjs');
7
5
 
6
+ var _chunkIAUV3UKHcjs = require('./chunk-IAUV3UKH.cjs');
7
+ require('./chunk-NU4F7G47.cjs');
8
8
 
9
- var _chunkJ7IF3KA3cjs = require('./chunk-J7IF3KA3.cjs');
10
9
 
11
- // src/components/index.ts
12
- _chunkJ7IF3KA3cjs.init_cjs_shims.call(void 0, );
13
10
 
14
11
 
15
-
16
-
17
- exports.Oas = _chunkUKUEVTRBcjs.Oas; exports.Operation = _chunkUKUEVTRBcjs.Operation; exports.Schema = _chunkUKUEVTRBcjs.Schema;
12
+ exports.Oas = _chunkIAUV3UKHcjs.Oas; exports.Operation = _chunkIAUV3UKHcjs.Operation; exports.Schema = _chunkIAUV3UKHcjs.Schema;
18
13
  //# sourceMappingURL=components.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/components.cjs","../src/components/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,8CAAA,CAAA;ADYA;AACE;AACA;AACA;AACF,gIAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/components.cjs","sourcesContent":[null,"export { Oas } from './Oas.tsx'\nexport { Operation } from './Operation.tsx'\nexport { Schema } from './Schema.tsx'\n"]}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/components.cjs"],"names":[],"mappings":"AAAA,yGAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACF,gIAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/components.cjs"}
@@ -1,12 +1,12 @@
1
- import { S as Schema } from './Schema-an5hOrjZ.cjs';
1
+ import { S as Schema } from './Schema-DoSFh7Qd.cjs';
2
2
  import * as react from 'react';
3
3
  import { Operation as Operation$1, Oas as Oas$1 } from '@kubb/oas';
4
- import { KubbNode } from '@kubb/react';
5
- import { a as OperationGenerator } from './OperationGenerator-CrCcKl3S.cjs';
4
+ import { KubbNode } from '@kubb/react/types';
5
+ import { a as OperationGenerator } from './OperationGenerator-Gd1X7wUz.cjs';
6
+ import './SchemaMapper-sGcY1xL5.cjs';
6
7
  import '@kubb/fs/types';
7
- import './SchemaMapper-CsBQ6eEx.cjs';
8
8
  import '@kubb/core';
9
- import './types-BP45TdiW.cjs';
9
+ import './types-CZTUCaE5.cjs';
10
10
  import '@kubb/oas/parser';
11
11
 
12
12
  type Props$1 = {
@@ -24,13 +24,19 @@ declare namespace Operation {
24
24
  type Props = {
25
25
  oas: Oas$1;
26
26
  operations?: Operation$1[];
27
- generator?: OperationGenerator;
27
+ /**
28
+ * @deprecated
29
+ */
30
+ generator?: Omit<OperationGenerator, 'build'>;
28
31
  children?: KubbNode;
29
32
  };
30
33
  type OasContextProps = {
31
34
  oas?: Oas$1;
32
35
  operations?: Operation$1[];
33
- generator?: OperationGenerator;
36
+ /**
37
+ * @deprecated
38
+ */
39
+ generator?: Omit<OperationGenerator, 'build'>;
34
40
  };
35
41
  declare function Oas({ oas, children, operations, generator }: Props): KubbNode;
36
42
  declare namespace Oas {
@@ -1,12 +1,12 @@
1
- import { S as Schema } from './Schema-DefwBJMc.js';
1
+ import { S as Schema } from './Schema-B1vcPGiK.js';
2
2
  import * as react from 'react';
3
3
  import { Operation as Operation$1, Oas as Oas$1 } from '@kubb/oas';
4
- import { KubbNode } from '@kubb/react';
5
- import { a as OperationGenerator } from './OperationGenerator-B0RLFu4P.js';
4
+ import { KubbNode } from '@kubb/react/types';
5
+ import { a as OperationGenerator } from './OperationGenerator-By5WOmWB.js';
6
+ import './SchemaMapper-sGcY1xL5.js';
6
7
  import '@kubb/fs/types';
7
- import './SchemaMapper-CsBQ6eEx.js';
8
8
  import '@kubb/core';
9
- import './types-BP45TdiW.js';
9
+ import './types-CZTUCaE5.js';
10
10
  import '@kubb/oas/parser';
11
11
 
12
12
  type Props$1 = {
@@ -24,13 +24,19 @@ declare namespace Operation {
24
24
  type Props = {
25
25
  oas: Oas$1;
26
26
  operations?: Operation$1[];
27
- generator?: OperationGenerator;
27
+ /**
28
+ * @deprecated
29
+ */
30
+ generator?: Omit<OperationGenerator, 'build'>;
28
31
  children?: KubbNode;
29
32
  };
30
33
  type OasContextProps = {
31
34
  oas?: Oas$1;
32
35
  operations?: Operation$1[];
33
- generator?: OperationGenerator;
36
+ /**
37
+ * @deprecated
38
+ */
39
+ generator?: Omit<OperationGenerator, 'build'>;
34
40
  };
35
41
  declare function Oas({ oas, children, operations, generator }: Props): KubbNode;
36
42
  declare namespace Oas {
@@ -1,15 +1,10 @@
1
+ import "./chunk-SQ64ESS4.js";
1
2
  import {
2
3
  Oas,
3
4
  Operation,
4
5
  Schema
5
- } from "./chunk-QSM6A5QX.js";
6
- import "./chunk-ZZ7ZC4TT.js";
7
- import {
8
- init_esm_shims
9
- } from "./chunk-Y272OQMW.js";
10
-
11
- // src/components/index.ts
12
- init_esm_shims();
6
+ } from "./chunk-M347763D.js";
7
+ import "./chunk-SZDO532A.js";
13
8
  export {
14
9
  Oas,
15
10
  Operation,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/index.ts"],"sourcesContent":["export { Oas } from './Oas.tsx'\nexport { Operation } from './Operation.tsx'\nexport { Schema } from './Schema.tsx'\n"],"mappings":";;;;;;;;;;;AAAA;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/hooks.cjs CHANGED
@@ -2,20 +2,19 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkUKUEVTRBcjs = require('./chunk-UKUEVTRB.cjs');
6
- require('./chunk-K4GEQ3C2.cjs');
5
+ var _chunkIAUV3UKHcjs = require('./chunk-IAUV3UKH.cjs');
7
6
 
8
7
 
9
- var _chunkJ7IF3KA3cjs = require('./chunk-J7IF3KA3.cjs');
8
+ var _chunkNU4F7G47cjs = require('./chunk-NU4F7G47.cjs');
10
9
 
11
10
  // src/hooks/index.ts
12
- _chunkJ7IF3KA3cjs.init_cjs_shims.call(void 0, );
11
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
13
12
 
14
13
  // src/hooks/useOas.ts
15
- _chunkJ7IF3KA3cjs.init_cjs_shims.call(void 0, );
14
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
16
15
  var _react = require('@kubb/react');
17
16
  function useOas() {
18
- const { oas } = _react.useContext.call(void 0, _chunkUKUEVTRBcjs.Oas.Context);
17
+ const { oas } = _react.useContext.call(void 0, _chunkIAUV3UKHcjs.Oas.Context);
19
18
  if (!oas) {
20
19
  throw new Error("Oas is not defined");
21
20
  }
@@ -23,10 +22,10 @@ function useOas() {
23
22
  }
24
23
 
25
24
  // src/hooks/useOperation.ts
26
- _chunkJ7IF3KA3cjs.init_cjs_shims.call(void 0, );
25
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
27
26
 
28
27
  function useOperation() {
29
- const { operation } = _react.useContext.call(void 0, _chunkUKUEVTRBcjs.Operation.Context);
28
+ const { operation } = _react.useContext.call(void 0, _chunkIAUV3UKHcjs.Operation.Context);
30
29
  if (!operation) {
31
30
  throw new Error("Operation is not defined");
32
31
  }
@@ -34,11 +33,11 @@ function useOperation() {
34
33
  }
35
34
 
36
35
  // src/hooks/useOperationManager.ts
37
- _chunkJ7IF3KA3cjs.init_cjs_shims.call(void 0, );
36
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
38
37
 
39
38
  function useOperationManager() {
40
39
  const { plugin, pluginManager } = _react.useApp.call(void 0, );
41
- const { generator } = _react.useContext.call(void 0, _chunkUKUEVTRBcjs.Oas.Context);
40
+ const { generator } = _react.useContext.call(void 0, _chunkIAUV3UKHcjs.Oas.Context);
42
41
  if (!generator) {
43
42
  throw new Error(`'generator' is not defined`);
44
43
  }
@@ -139,10 +138,10 @@ function useOperationManager() {
139
138
  }
140
139
 
141
140
  // src/hooks/useOperations.ts
142
- _chunkJ7IF3KA3cjs.init_cjs_shims.call(void 0, );
141
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
143
142
 
144
143
  function useOperations({ method, path } = {}) {
145
- const { operations } = _react.useContext.call(void 0, _chunkUKUEVTRBcjs.Oas.Context);
144
+ const { operations } = _react.useContext.call(void 0, _chunkIAUV3UKHcjs.Oas.Context);
146
145
  if (!operations) {
147
146
  throw new Error("Operations is not defined");
148
147
  }
@@ -161,5 +160,5 @@ function useOperations({ method, path } = {}) {
161
160
 
162
161
 
163
162
 
164
- exports.useOas = useOas; exports.useOperation = useOperation; exports.useOperationManager = useOperationManager; exports.useOperations = useOperations; exports.useSchema = _chunkUKUEVTRBcjs.useSchema;
163
+ exports.useOas = useOas; exports.useOperation = useOperation; exports.useOperationManager = useOperationManager; exports.useOperations = useOperations; exports.useSchema = _chunkIAUV3UKHcjs.useSchema;
165
164
  //# sourceMappingURL=hooks.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/hooks.cjs","../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],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KAAA,CAAM,MAAA,CAAO,CAAC,IAAA,EAAA,GAAS,IAAA,CAAK,KAAA,IAAS,IAAI,CAAA;AAAA,EACnD;AAEA,EAAA,GAAA,CAAI,MAAA,EAAQ;AACV,IAAA,MAAA,EAAQ,KAAA,CAAM,MAAA,CAAO,CAAC,IAAA,EAAA,GAAS,IAAA,CAAK,OAAA,IAAW,MAAM,CAAA;AAAA,EACvD;AAEA,EAAA,OAAO,KAAA;AACT;ALsHA;AACE;AACA;AACA;AACA;AACA;AACF,wMAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/hooks.cjs","sourcesContent":[null,"export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\n","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 { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype 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: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (operation: OperationType, params?: { pluginKey?: Plugin['key']; extName?: KubbFile.Extname }) => KubbFile.File<FileMeta>\n groupSchemasByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames\n getSchemas: (\n operation: Operation,\n params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] },\n forStatusCode?: string | number,\n ) => OperationSchemas\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, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const getName: UseOperationManagerResult['getName'] = (operation, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: operation.getOperationId(),\n pluginKey,\n type,\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { pluginKey = plugin.key, extName = '.ts' } = {}) => {\n // needed for the `output.group`\n const tag = operation.getTags().at(0)?.name\n const name = getName(operation, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name,\n extName,\n pluginKey,\n options: { type: 'file', pluginKey, tag },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n tag,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\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 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 [schemas.response.statusCode || 'default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\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: (operation, params, forStatusCode) =>\n generator.getSchemas(operation, {\n forStatusCode,\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n }),\n groupSchemasByName,\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"]}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/hooks.cjs","../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],"names":["useContext"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA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AA,EACnD;AAEA,EAAA,GAAA,CAAI,MAAA,EAAQ;AACV,IAAA,MAAA,EAAQ,KAAA,CAAM,MAAA,CAAO,CAAC,IAAA,EAAA,GAAS,IAAA,CAAK,OAAA,IAAW,MAAM,CAAA;AAAA,EACvD;AAEA,EAAA,OAAO,KAAA;AACT;ALqHA;AACE;AACA;AACA;AACA;AACA;AACF,wMAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/hooks.cjs","sourcesContent":[null,"export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\n","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 { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype 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: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (operation: OperationType, params?: { pluginKey?: Plugin['key']; extName?: KubbFile.Extname }) => KubbFile.File<FileMeta>\n groupSchemasByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames\n getSchemas: (\n operation: Operation,\n params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] },\n forStatusCode?: string | number,\n ) => OperationSchemas\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, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const getName: UseOperationManagerResult['getName'] = (operation, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: operation.getOperationId(),\n pluginKey,\n type,\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { pluginKey = plugin.key, extName = '.ts' } = {}) => {\n // needed for the `output.group`\n const tag = operation.getTags().at(0)?.name\n //TODO replace with group\n const name = getName(operation, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name,\n extName,\n pluginKey,\n options: { type: 'file', pluginKey, tag },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n tag,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\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 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 [schemas.response.statusCode || 'default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\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: (operation, params, forStatusCode) =>\n generator.getSchemas(operation, {\n forStatusCode,\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n }),\n groupSchemasByName,\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"]}
package/dist/hooks.d.cts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Oas, Operation, HttpMethod } from '@kubb/oas';
2
2
  import { Plugin, ResolveNameParams, FileMetaBase } from '@kubb/core';
3
3
  import * as KubbFile from '@kubb/fs/types';
4
- import { f as OperationSchemas } from './types-BP45TdiW.cjs';
5
- import { a as SchemaContextProps } from './Schema-an5hOrjZ.cjs';
4
+ import { e as OperationSchemas } from './types-CZTUCaE5.cjs';
5
+ import { a as SchemaContextProps } from './Schema-DoSFh7Qd.cjs';
6
6
  import '@kubb/oas/parser';
7
7
  import 'react';
8
- import '@kubb/react';
9
- import './SchemaMapper-CsBQ6eEx.cjs';
8
+ import '@kubb/react/types';
9
+ import './SchemaMapper-sGcY1xL5.cjs';
10
10
 
11
11
  declare function useOas(): Oas;
12
12
 
package/dist/hooks.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Oas, Operation, HttpMethod } from '@kubb/oas';
2
2
  import { Plugin, ResolveNameParams, FileMetaBase } from '@kubb/core';
3
3
  import * as KubbFile from '@kubb/fs/types';
4
- import { f as OperationSchemas } from './types-BP45TdiW.js';
5
- import { a as SchemaContextProps } from './Schema-DefwBJMc.js';
4
+ import { e as OperationSchemas } from './types-CZTUCaE5.js';
5
+ import { a as SchemaContextProps } from './Schema-B1vcPGiK.js';
6
6
  import '@kubb/oas/parser';
7
7
  import 'react';
8
- import '@kubb/react';
9
- import './SchemaMapper-CsBQ6eEx.js';
8
+ import '@kubb/react/types';
9
+ import './SchemaMapper-sGcY1xL5.js';
10
10
 
11
11
  declare function useOas(): Oas;
12
12
 
package/dist/hooks.js CHANGED
@@ -2,11 +2,10 @@ import {
2
2
  Oas,
3
3
  Operation,
4
4
  useSchema
5
- } from "./chunk-QSM6A5QX.js";
6
- import "./chunk-ZZ7ZC4TT.js";
5
+ } from "./chunk-M347763D.js";
7
6
  import {
8
7
  init_esm_shims
9
- } from "./chunk-Y272OQMW.js";
8
+ } from "./chunk-SZDO532A.js";
10
9
 
11
10
  // src/hooks/index.ts
12
11
  init_esm_shims();
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],"sourcesContent":["export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\n","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 { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype 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: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (operation: OperationType, params?: { pluginKey?: Plugin['key']; extName?: KubbFile.Extname }) => KubbFile.File<FileMeta>\n groupSchemasByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames\n getSchemas: (\n operation: Operation,\n params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] },\n forStatusCode?: string | number,\n ) => OperationSchemas\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, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const getName: UseOperationManagerResult['getName'] = (operation, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: operation.getOperationId(),\n pluginKey,\n type,\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { pluginKey = plugin.key, extName = '.ts' } = {}) => {\n // needed for the `output.group`\n const tag = operation.getTags().at(0)?.name\n const name = getName(operation, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name,\n extName,\n pluginKey,\n options: { type: 'file', pluginKey, tag },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n tag,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\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 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 [schemas.response.statusCode || 'default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\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: (operation, params, forStatusCode) =>\n generator.getSchemas(operation, {\n forStatusCode,\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n }),\n groupSchemasByName,\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"],"mappings":";;;;;;;;;;;AAAA;;;ACAA;AAAA,SAAS,kBAAkB;AAMpB,SAAS,SAAkB;AAChC,QAAM,EAAE,IAAI,IAAI,WAAW,IAAI,OAAO;AAEtC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,oBAAoB;AAAA,EACtC;AAEA,SAAO;AACT;;;ACdA;AAAA,SAAS,cAAAA,mBAAkB;AASpB,SAAS,eAA8B;AAC5C,QAAM,EAAE,UAAU,IAAIC,YAAW,UAAU,OAAO;AAElD,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAC5C;AAEA,SAAO;AACT;;;ACjBA;AAAA,SAAS,QAAQ,cAAAC,mBAAkB;AAwC5B,SAAS,sBAAiD;AAC/D,QAAM,EAAE,QAAQ,cAAc,IAAI,OAAO;AACzC,QAAM,EAAE,UAAU,IAAIC,YAAW,IAAI,OAAO;AAE5C,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAC9C;AAEA,QAAM,UAAgD,CAAC,WAAW,EAAE,YAAY,OAAO,KAAK,KAAK,MAAM;AACrG,WAAO,cAAc,YAAY;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AW,MAAM;AAAA,EACvD;AAEA,SAAO;AACT;","names":["useContext","useContext","useContext","useContext","useContext","useContext"]}
1
+ {"version":3,"sources":["../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],"sourcesContent":["export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\n","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 { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype 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: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (operation: OperationType, params?: { pluginKey?: Plugin['key']; extName?: KubbFile.Extname }) => KubbFile.File<FileMeta>\n groupSchemasByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames\n getSchemas: (\n operation: Operation,\n params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] },\n forStatusCode?: string | number,\n ) => OperationSchemas\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, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const getName: UseOperationManagerResult['getName'] = (operation, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: operation.getOperationId(),\n pluginKey,\n type,\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { pluginKey = plugin.key, extName = '.ts' } = {}) => {\n // needed for the `output.group`\n const tag = operation.getTags().at(0)?.name\n //TODO replace with group\n const name = getName(operation, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name,\n extName,\n pluginKey,\n options: { type: 'file', pluginKey, tag },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n tag,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\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 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 [schemas.response.statusCode || 'default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\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: (operation, params, forStatusCode) =>\n generator.getSchemas(operation, {\n forStatusCode,\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n }),\n groupSchemasByName,\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"],"mappings":";;;;;;;;;;AAAA;;;ACAA;AAAA,SAAS,kBAAkB;AAMpB,SAAS,SAAkB;AAChC,QAAM,EAAE,IAAI,IAAI,WAAW,IAAI,OAAO;AAEtC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,oBAAoB;AAAA,EACtC;AAEA,SAAO;AACT;;;ACdA;AAAA,SAAS,cAAAA,mBAAkB;AASpB,SAAS,eAA8B;AAC5C,QAAM,EAAE,UAAU,IAAIC,YAAW,UAAU,OAAO;AAElD,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAC5C;AAEA,SAAO;AACT;;;ACjBA;A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