@kubb/plugin-oas 2.19.5 → 2.20.0

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 (43) hide show
  1. package/dist/{OperationGenerator-BL3W1CH2.d.ts → OperationGenerator-8DNneYd8.d.ts} +4 -1
  2. package/dist/{OperationGenerator-B6_KXF47.d.cts → OperationGenerator-BHo9OWOG.d.cts} +4 -1
  3. package/dist/{chunk-3NSBUDVM.js → chunk-5PS7VSVP.js} +34 -41
  4. package/dist/{chunk-3NSBUDVM.js.map → chunk-5PS7VSVP.js.map} +1 -1
  5. package/dist/{chunk-SXUTBEJ7.js → chunk-7KC6HDZA.js} +11 -25
  6. package/dist/{chunk-SXUTBEJ7.js.map → chunk-7KC6HDZA.js.map} +1 -1
  7. package/dist/{chunk-I5KLDP43.cjs → chunk-C4DNEBEV.cjs} +65 -94
  8. package/dist/chunk-C4DNEBEV.cjs.map +1 -0
  9. package/dist/{chunk-USWJ3LIC.cjs → chunk-ERS2ZSAT.cjs} +40 -47
  10. package/dist/chunk-ERS2ZSAT.cjs.map +1 -0
  11. package/dist/{chunk-YS56QITS.cjs → chunk-GWI26OTO.cjs} +11 -25
  12. package/dist/chunk-GWI26OTO.cjs.map +1 -0
  13. package/dist/{chunk-WEZ6CODU.cjs → chunk-I5OXSD6K.cjs} +3 -3
  14. package/dist/{chunk-FDLHRTTS.js → chunk-N6CQRWVS.js} +2 -2
  15. package/dist/{chunk-CBVKDLCJ.js → chunk-YPTFMYOL.js} +45 -74
  16. package/dist/{chunk-CBVKDLCJ.js.map → chunk-YPTFMYOL.js.map} +1 -1
  17. package/dist/components.cjs +5 -5
  18. package/dist/components.d.cts +1 -1
  19. package/dist/components.d.ts +1 -1
  20. package/dist/components.js +3 -3
  21. package/dist/hooks.cjs +31 -18
  22. package/dist/hooks.cjs.map +1 -1
  23. package/dist/hooks.d.cts +9 -3
  24. package/dist/hooks.d.ts +9 -3
  25. package/dist/hooks.js +21 -8
  26. package/dist/hooks.js.map +1 -1
  27. package/dist/index.cjs +37 -43
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +1 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.js +26 -32
  32. package/dist/index.js.map +1 -1
  33. package/dist/utils.cjs +8 -8
  34. package/dist/utils.js +2 -2
  35. package/package.json +11 -11
  36. package/src/OperationGenerator.ts +10 -7
  37. package/src/SchemaGenerator.ts +8 -2
  38. package/src/hooks/useOperationManager.ts +27 -7
  39. package/dist/chunk-I5KLDP43.cjs.map +0 -1
  40. package/dist/chunk-USWJ3LIC.cjs.map +0 -1
  41. package/dist/chunk-YS56QITS.cjs.map +0 -1
  42. /package/dist/{chunk-WEZ6CODU.cjs.map → chunk-I5OXSD6K.cjs.map} +0 -0
  43. /package/dist/{chunk-FDLHRTTS.js.map → chunk-N6CQRWVS.js.map} +0 -0
@@ -2,17 +2,17 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkI5KLDP43cjs = require('./chunk-I5KLDP43.cjs');
6
- require('./chunk-USWJ3LIC.cjs');
5
+ var _chunkC4DNEBEVcjs = require('./chunk-C4DNEBEV.cjs');
6
+ require('./chunk-ERS2ZSAT.cjs');
7
7
 
8
8
 
9
- var _chunkYS56QITScjs = require('./chunk-YS56QITS.cjs');
9
+ var _chunkGWI26OTOcjs = require('./chunk-GWI26OTO.cjs');
10
10
 
11
11
  // src/components/index.ts
12
- _chunkYS56QITScjs.init_cjs_shims.call(void 0, );
12
+ _chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
13
13
 
14
14
 
15
15
 
16
16
 
17
- exports.Oas = _chunkI5KLDP43cjs.Oas; exports.Operation = _chunkI5KLDP43cjs.Operation; exports.Schema = _chunkI5KLDP43cjs.Schema;
17
+ exports.Oas = _chunkC4DNEBEVcjs.Oas; exports.Operation = _chunkC4DNEBEVcjs.Operation; exports.Schema = _chunkC4DNEBEVcjs.Schema;
18
18
  //# sourceMappingURL=components.cjs.map
@@ -2,7 +2,7 @@ import { S as Schema } from './Schema-FGI5VPqc.cjs';
2
2
  import * as react from 'react';
3
3
  import { Operation as Operation$1, Oas as Oas$1 } from '@kubb/oas';
4
4
  import { KubbNode } from '@kubb/react';
5
- import { a as OperationGenerator } from './OperationGenerator-B6_KXF47.cjs';
5
+ import { a as OperationGenerator } from './OperationGenerator-BHo9OWOG.cjs';
6
6
  import './SchemaMapper-CsBQ6eEx.cjs';
7
7
  import '@kubb/fs/types';
8
8
  import '@kubb/core';
@@ -2,7 +2,7 @@ import { S as Schema } from './Schema-D41ItX9C.js';
2
2
  import * as react from 'react';
3
3
  import { Operation as Operation$1, Oas as Oas$1 } from '@kubb/oas';
4
4
  import { KubbNode } from '@kubb/react';
5
- import { a as OperationGenerator } from './OperationGenerator-BL3W1CH2.js';
5
+ import { a as OperationGenerator } from './OperationGenerator-8DNneYd8.js';
6
6
  import './SchemaMapper-CsBQ6eEx.js';
7
7
  import '@kubb/fs/types';
8
8
  import '@kubb/core';
@@ -2,11 +2,11 @@ import {
2
2
  Oas,
3
3
  Operation,
4
4
  Schema
5
- } from "./chunk-CBVKDLCJ.js";
6
- import "./chunk-3NSBUDVM.js";
5
+ } from "./chunk-YPTFMYOL.js";
6
+ import "./chunk-5PS7VSVP.js";
7
7
  import {
8
8
  init_esm_shims
9
- } from "./chunk-SXUTBEJ7.js";
9
+ } from "./chunk-7KC6HDZA.js";
10
10
 
11
11
  // src/components/index.ts
12
12
  init_esm_shims();
package/dist/hooks.cjs CHANGED
@@ -2,20 +2,20 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkI5KLDP43cjs = require('./chunk-I5KLDP43.cjs');
6
- require('./chunk-USWJ3LIC.cjs');
5
+ var _chunkC4DNEBEVcjs = require('./chunk-C4DNEBEV.cjs');
6
+ require('./chunk-ERS2ZSAT.cjs');
7
7
 
8
8
 
9
- var _chunkYS56QITScjs = require('./chunk-YS56QITS.cjs');
9
+ var _chunkGWI26OTOcjs = require('./chunk-GWI26OTO.cjs');
10
10
 
11
11
  // src/hooks/index.ts
12
- _chunkYS56QITScjs.init_cjs_shims.call(void 0, );
12
+ _chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
13
13
 
14
14
  // src/hooks/useOas.ts
15
- _chunkYS56QITScjs.init_cjs_shims.call(void 0, );
15
+ _chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
16
16
  var _react = require('@kubb/react');
17
17
  function useOas() {
18
- const { oas } = _react.useContext.call(void 0, _chunkI5KLDP43cjs.Oas.Context);
18
+ const { oas } = _react.useContext.call(void 0, _chunkC4DNEBEVcjs.Oas.Context);
19
19
  if (!oas) {
20
20
  throw new Error("Oas is not defined");
21
21
  }
@@ -23,10 +23,10 @@ function useOas() {
23
23
  }
24
24
 
25
25
  // src/hooks/useOperation.ts
26
- _chunkYS56QITScjs.init_cjs_shims.call(void 0, );
26
+ _chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
27
27
 
28
28
  function useOperation() {
29
- const { operation } = _react.useContext.call(void 0, _chunkI5KLDP43cjs.Operation.Context);
29
+ const { operation } = _react.useContext.call(void 0, _chunkC4DNEBEVcjs.Operation.Context);
30
30
  if (!operation) {
31
31
  throw new Error("Operation is not defined");
32
32
  }
@@ -34,11 +34,11 @@ function useOperation() {
34
34
  }
35
35
 
36
36
  // src/hooks/useOperationManager.ts
37
- _chunkYS56QITScjs.init_cjs_shims.call(void 0, );
37
+ _chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
38
38
 
39
39
  function useOperationManager() {
40
40
  const { plugin, pluginManager } = _react.useApp.call(void 0, );
41
- const { generator } = _react.useContext.call(void 0, _chunkI5KLDP43cjs.Oas.Context);
41
+ const { generator } = _react.useContext.call(void 0, _chunkC4DNEBEVcjs.Oas.Context);
42
42
  if (!generator) {
43
43
  throw new Error(`'generator' is not defined`);
44
44
  }
@@ -68,7 +68,7 @@ function useOperationManager() {
68
68
  }
69
69
  };
70
70
  };
71
- const groupSchemasByByName = (operation, { pluginKey = plugin.key, type }) => {
71
+ const groupSchemasByName = (operation, { pluginKey = plugin.key, type }) => {
72
72
  const schemas = generator.getSchemas(operation);
73
73
  const errors = (schemas.errors || []).reduce(
74
74
  (prev, acc) => {
@@ -77,7 +77,7 @@ function useOperationManager() {
77
77
  }
78
78
  prev[acc.statusCode] = pluginManager.resolveName({
79
79
  name: acc.name,
80
- pluginKey: plugin.key,
80
+ pluginKey,
81
81
  type
82
82
  });
83
83
  return prev;
@@ -113,23 +113,36 @@ function useOperationManager() {
113
113
  pluginKey,
114
114
  type
115
115
  }),
116
+ ["default"]: pluginManager.resolveName({
117
+ name: schemas.response.name,
118
+ pluginKey,
119
+ type
120
+ }),
116
121
  ...errors
117
- }
122
+ },
123
+ errors
118
124
  };
119
125
  };
120
126
  return {
121
127
  getName,
122
128
  getFile,
123
- getSchemas: (operation, forStatusCode) => generator.getSchemas(operation, forStatusCode),
124
- groupSchemasByByName
129
+ getSchemas: (operation, params, forStatusCode) => generator.getSchemas(operation, {
130
+ forStatusCode,
131
+ resolveName: (name) => pluginManager.resolveName({
132
+ name,
133
+ pluginKey: _optionalChain([params, 'optionalAccess', _14 => _14.pluginKey]),
134
+ type: _optionalChain([params, 'optionalAccess', _15 => _15.type])
135
+ })
136
+ }),
137
+ groupSchemasByName
125
138
  };
126
139
  }
127
140
 
128
141
  // src/hooks/useOperations.ts
129
- _chunkYS56QITScjs.init_cjs_shims.call(void 0, );
142
+ _chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
130
143
 
131
144
  function useOperations({ method, path } = {}) {
132
- const { operations } = _react.useContext.call(void 0, _chunkI5KLDP43cjs.Oas.Context);
145
+ const { operations } = _react.useContext.call(void 0, _chunkC4DNEBEVcjs.Oas.Context);
133
146
  if (!operations) {
134
147
  throw new Error("Operations is not defined");
135
148
  }
@@ -148,5 +161,5 @@ function useOperations({ method, path } = {}) {
148
161
 
149
162
 
150
163
 
151
- exports.useOas = useOas; exports.useOperation = useOperation; exports.useOperationManager = useOperationManager; exports.useOperations = useOperations; exports.useSchema = _chunkI5KLDP43cjs.useSchema;
164
+ exports.useOas = useOas; exports.useOperation = useOperation; exports.useOperationManager = useOperationManager; exports.useOperations = useOperations; exports.useSchema = _chunkC4DNEBEVcjs.useSchema;
152
165
  //# sourceMappingURL=hooks.cjs.map
@@ -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"],"names":["useContext"],"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,IAAIA,YAAW,UAAU,OAAO;AAElD,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAC5C;AAEA,SAAO;AACT;;;ACjBA;AAAA,SAAS,QAAQ,cAAAA,mBAAkB;AAmC5B,SAAS,sBAAiD;AAC/D,QAAM,EAAE,QAAQ,cAAc,IAAI,OAAO;AACzC,QAAM,EAAE,UAAU,IAAIA,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;AAAA,MAC/B,MAAM,UAAU,eAAe;AAAA,MAC/B;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,UAAgD,CAAC,WAAW,EAAE,YAAY,OAAO,KAAK,UAAU,MAAM,IAAI,CAAC,MAAM;AAErH,UAAM,MAAM,UAAU,QAAQ,EA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AQ,aAAa;AAAA,UAC3B;AAAA,UACA;AAAA,QACF,CAAC,IACD;AAAA,MACN;AAAA,MACA,WAAW;AAAA,QACT,CAAC,QAAQ,SAAS,cAAc,SAAS,GAAG,cAAc,YAAY;AAAA,UACpE,MAAM,QAAQ,SAAS;AAAA,UACvB;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,YAAY,CAAC,WAAW,kBAAkB,UAAU,WAAW,WAAW,aAAa;AAAA,IACvF;AAAA,EACF;AACF;;;AC9IA;AAAA,SAAS,cAAAA,mBAAkB;AAsBpB,SAAS,cAAc,EAAE,QAAQ,KAAK,IAAwB,CAAC,GAAgB;AACpF,QAAM,EAAE,WAAW,IAAIA,YAAW,IAAI,OAAO;AAE7C,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,2BAA2B;AAAA,EAC7C;AACA,MAAI,QAAQ;AAEZ,MAAI,MAAM;AACR,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI;AAAA,EACnD;AAEA,MAAI,QAAQ;AACV,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,WAAW,MAAM;AAAA,EACvD;AAEA,SAAO;AACT","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: Record<number, 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 groupSchemasByByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames\n getSchemas: (operation: Operation, forStatusCode?: string | number) => 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 groupSchemasByByName: UseOperationManagerResult['groupSchemasByByName'] = (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: plugin.key,\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 ...errors,\n },\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas: (operation, forStatusCode) => generator.getSchemas(operation, forStatusCode),\n groupSchemasByByName,\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":["../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],"names":["useContext"],"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,IAAIA,YAAW,UAAU,OAAO;AAElD,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAC5C;AAEA,SAAO;AACT;;;ACjBA;AAAA,SAAS,QAAQ,cAAAA,mBAAkB;AAwC5B,SAAS,sBAAiD;AAC/D,QAAM,EAAE,QAAQ,cAAc,IAAI,OAAO;AACzC,QAAM,EAAE,UAAU,IAAIA,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;AAAA,MAC/B,MAAM,UAAU,eAAe;AAAA,MAC/B;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,UAAgD,CAAC,WAAW,EAAE,YAAY,OAAO,KAAK,UAAU,MAAM,IAAI,CAAC,MAAM;AAErH,UAAM,MAAM,UAAU,QAAQ,EAAE,GAAG,CAAC,GAAG;AACvC,UAAM,OAAO,QAAQ,WAAW,EAAE,MAAM,QAAQ,UAAU,CAAC;AAE3D,UAAM,OAAO,cAAc,QAAQ;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,EAAE,MAAM,QAAQ,WAAW,IAAI;A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C;AAAA,QACD,CAAC,SAAS,GAAG,cAAc,YAAY;AAAA,UACrC,MAAM,QAAQ,SAAS;AAAA,UACvB;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD,GAAG;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,YAAY,CAAC,WAAW,QAAQ,kBAC9B,UAAU,WAAW,WAAW;AAAA,MAC9B;AAAA,MACA,aAAa,CAAC,SACZ,cAAc,YAAY;AAAA,QACxB;AAAA,QACA,WAAW,QAAQ;AAAA,QACnB,MAAM,QAAQ;AAAA,MAChB,CAAC;AAAA,IACL,CAAC;AAAA,IACH;AAAA,EACF;AACF;;;AClKA;AAAA,SAAS,cAAAA,mBAAkB;AAsBpB,SAAS,cAAc,EAAE,QAAQ,KAAK,IAAwB,CAAC,GAAgB;AACpF,QAAM,EAAE,WAAW,IAAIA,YAAW,IAAI,OAAO;AAE7C,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,2BAA2B;AAAA,EAC7C;AACA,MAAI,QAAQ;AAEZ,MAAI,MAAM;AACR,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI;AAAA,EACnD;AAEA,MAAI,QAAQ;AACV,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,WAAW,MAAM;AAAA,EACvD;AAEA,SAAO;AACT","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"]}
package/dist/hooks.d.cts CHANGED
@@ -27,7 +27,10 @@ type SchemaNames = {
27
27
  query: string | undefined;
28
28
  header: string | undefined;
29
29
  };
30
- responses: Record<number, string>;
30
+ responses: {
31
+ default?: string;
32
+ } & Record<number | string, string>;
33
+ errors: Record<number | string, string>;
31
34
  };
32
35
  type UseOperationManagerResult = {
33
36
  getName: (operation: Operation, params: {
@@ -38,11 +41,14 @@ type UseOperationManagerResult = {
38
41
  pluginKey?: Plugin['key'];
39
42
  extName?: KubbFile.Extname;
40
43
  }) => KubbFile.File<FileMeta>;
41
- groupSchemasByByName: (operation: Operation, params: {
44
+ groupSchemasByName: (operation: Operation, params: {
42
45
  pluginKey?: Plugin['key'];
43
46
  type: ResolveNameParams['type'];
44
47
  }) => SchemaNames;
45
- getSchemas: (operation: Operation, forStatusCode?: string | number) => OperationSchemas;
48
+ getSchemas: (operation: Operation, params?: {
49
+ pluginKey?: Plugin['key'];
50
+ type?: ResolveNameParams['type'];
51
+ }, forStatusCode?: string | number) => OperationSchemas;
46
52
  };
47
53
  /**
48
54
  * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.
package/dist/hooks.d.ts CHANGED
@@ -27,7 +27,10 @@ type SchemaNames = {
27
27
  query: string | undefined;
28
28
  header: string | undefined;
29
29
  };
30
- responses: Record<number, string>;
30
+ responses: {
31
+ default?: string;
32
+ } & Record<number | string, string>;
33
+ errors: Record<number | string, string>;
31
34
  };
32
35
  type UseOperationManagerResult = {
33
36
  getName: (operation: Operation, params: {
@@ -38,11 +41,14 @@ type UseOperationManagerResult = {
38
41
  pluginKey?: Plugin['key'];
39
42
  extName?: KubbFile.Extname;
40
43
  }) => KubbFile.File<FileMeta>;
41
- groupSchemasByByName: (operation: Operation, params: {
44
+ groupSchemasByName: (operation: Operation, params: {
42
45
  pluginKey?: Plugin['key'];
43
46
  type: ResolveNameParams['type'];
44
47
  }) => SchemaNames;
45
- getSchemas: (operation: Operation, forStatusCode?: string | number) => OperationSchemas;
48
+ getSchemas: (operation: Operation, params?: {
49
+ pluginKey?: Plugin['key'];
50
+ type?: ResolveNameParams['type'];
51
+ }, forStatusCode?: string | number) => OperationSchemas;
46
52
  };
47
53
  /**
48
54
  * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.
package/dist/hooks.js CHANGED
@@ -2,11 +2,11 @@ import {
2
2
  Oas,
3
3
  Operation,
4
4
  useSchema
5
- } from "./chunk-CBVKDLCJ.js";
6
- import "./chunk-3NSBUDVM.js";
5
+ } from "./chunk-YPTFMYOL.js";
6
+ import "./chunk-5PS7VSVP.js";
7
7
  import {
8
8
  init_esm_shims
9
- } from "./chunk-SXUTBEJ7.js";
9
+ } from "./chunk-7KC6HDZA.js";
10
10
 
11
11
  // src/hooks/index.ts
12
12
  init_esm_shims();
@@ -68,7 +68,7 @@ function useOperationManager() {
68
68
  }
69
69
  };
70
70
  };
71
- const groupSchemasByByName = (operation, { pluginKey = plugin.key, type }) => {
71
+ const groupSchemasByName = (operation, { pluginKey = plugin.key, type }) => {
72
72
  const schemas = generator.getSchemas(operation);
73
73
  const errors = (schemas.errors || []).reduce(
74
74
  (prev, acc) => {
@@ -77,7 +77,7 @@ function useOperationManager() {
77
77
  }
78
78
  prev[acc.statusCode] = pluginManager.resolveName({
79
79
  name: acc.name,
80
- pluginKey: plugin.key,
80
+ pluginKey,
81
81
  type
82
82
  });
83
83
  return prev;
@@ -113,15 +113,28 @@ function useOperationManager() {
113
113
  pluginKey,
114
114
  type
115
115
  }),
116
+ ["default"]: pluginManager.resolveName({
117
+ name: schemas.response.name,
118
+ pluginKey,
119
+ type
120
+ }),
116
121
  ...errors
117
- }
122
+ },
123
+ errors
118
124
  };
119
125
  };
120
126
  return {
121
127
  getName,
122
128
  getFile,
123
- getSchemas: (operation, forStatusCode) => generator.getSchemas(operation, forStatusCode),
124
- groupSchemasByByName
129
+ getSchemas: (operation, params, forStatusCode) => generator.getSchemas(operation, {
130
+ forStatusCode,
131
+ resolveName: (name) => pluginManager.resolveName({
132
+ name,
133
+ pluginKey: params?.pluginKey,
134
+ type: params?.type
135
+ })
136
+ }),
137
+ groupSchemasByName
125
138
  };
126
139
  }
127
140
 
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: Record<number, 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 groupSchemasByByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames\n getSchemas: (operation: Operation, forStatusCode?: string | number) => 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 groupSchemasByByName: UseOperationManagerResult['groupSchemasByByName'] = (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: plugin.key,\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 ...errors,\n },\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas: (operation, forStatusCode) => generator.getSchemas(operation, forStatusCode),\n groupSchemasByByName,\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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;AAEZ,MAAI,MAAM;AACR,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI;AAAA,EACnD;AAEA,MAAI,QAAQ;AACV,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,WAAW,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 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,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QAAQ;AAAA,MAChB,CAAC;AAAA,IACL,CAAC;AAAA,IACH;AAAA,EACF;AACF;;;AClKA;AAAA,SAAS,cAAAC,mBAAkB;AAsBpB,SAAS,cAAc,EAAE,QAAQ,KAAK,IAAwB,CAAC,GAAgB;AACpF,QAAM,EAAE,WAAW,IAAIC,YAAW,IAAI,OAAO;AAE7C,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,2BAA2B;AAAA,EAC7C;AACA,MAAI,QAAQ;AAEZ,MAAI,MAAM;AACR,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI;AAAA,EACnD;AAEA,MAAI,QAAQ;AACV,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,WAAW,MAAM;AAAA,EACvD;AAEA,SAAO;AACT;","names":["useContext","useContext","useContext","useContext","useContext","useContext"]}
package/dist/index.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkWEZ6CODUcjs = require('./chunk-WEZ6CODU.cjs');
3
+ var _chunkI5OXSD6Kcjs = require('./chunk-I5OXSD6K.cjs');
4
4
 
5
5
 
6
6
 
7
7
 
8
- var _chunkUSWJ3LICcjs = require('./chunk-USWJ3LIC.cjs');
8
+ var _chunkERS2ZSATcjs = require('./chunk-ERS2ZSAT.cjs');
9
9
 
10
10
 
11
11
 
@@ -13,13 +13,13 @@ var _chunkUSWJ3LICcjs = require('./chunk-USWJ3LIC.cjs');
13
13
 
14
14
 
15
15
 
16
- var _chunkYS56QITScjs = require('./chunk-YS56QITS.cjs');
16
+ var _chunkGWI26OTOcjs = require('./chunk-GWI26OTO.cjs');
17
17
 
18
18
  // src/index.ts
19
- _chunkYS56QITScjs.init_cjs_shims.call(void 0, );
19
+ _chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
20
20
 
21
21
  // src/plugin.ts
22
- _chunkYS56QITScjs.init_cjs_shims.call(void 0, );
22
+ _chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
23
23
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
24
24
  var _core = require('@kubb/core');
25
25
  var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
@@ -35,7 +35,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
35
35
  } = options;
36
36
  const getOas = async ({ config, logger, formatOptions }) => {
37
37
  try {
38
- const oas = await _chunkWEZ6CODUcjs.parseFromConfig.call(void 0, config, formatOptions);
38
+ const oas = await _chunkI5OXSD6Kcjs.parseFromConfig.call(void 0, config, formatOptions);
39
39
  if (validate) {
40
40
  await oas.valdiate();
41
41
  }
@@ -43,7 +43,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
43
43
  } catch (e) {
44
44
  const error = e;
45
45
  logger.emit("warning", _optionalChain([error, 'optionalAccess', _ => _.message]));
46
- return _chunkWEZ6CODUcjs.parseFromConfig.call(void 0, config);
46
+ return _chunkI5OXSD6Kcjs.parseFromConfig.call(void 0, config);
47
47
  }
48
48
  };
49
49
  return {
@@ -57,7 +57,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
57
57
  },
58
58
  async getSchemas({ includes } = {}) {
59
59
  const oas = await this.getOas();
60
- return _chunkYS56QITScjs.getSchemas.call(void 0, { oas, contentType, includes });
60
+ return _chunkGWI26OTOcjs.getSchemas.call(void 0, { oas, contentType, includes });
61
61
  },
62
62
  async getBaseURL() {
63
63
  const oasInstance = await this.getOas();
@@ -96,7 +96,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
96
96
  }
97
97
  });
98
98
  await oas.dereference();
99
- const schemas = _chunkYS56QITScjs.getSchemas.call(void 0, { oas, contentType });
99
+ const schemas = _chunkGWI26OTOcjs.getSchemas.call(void 0, { oas, contentType });
100
100
  const mapSchema = async ([name, schema]) => {
101
101
  const resolvedPath = this.resolvePath({
102
102
  baseName: `${name}.json`,
@@ -126,34 +126,23 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
126
126
  });
127
127
 
128
128
  // src/OperationGenerator.ts
129
- _chunkYS56QITScjs.init_cjs_shims.call(void 0, );
129
+ _chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
130
130
 
131
131
 
132
- var _operationsByMethod, _getOptions, getOptions_fn, _isExcluded, isExcluded_fn, _isIncluded, isIncluded_fn, _methods, methods_get;
132
+ var _operationsByMethod, _OperationGenerator_instances, getOptions_fn, isExcluded_fn, isIncluded_fn, methods_get;
133
133
  var OperationGenerator = class extends _core.Generator {
134
134
  constructor() {
135
135
  super(...arguments);
136
- _chunkYS56QITScjs.__privateAdd.call(void 0, this, _getOptions);
137
- /**
138
- *
139
- * @deprecated
140
- */
141
- _chunkYS56QITScjs.__privateAdd.call(void 0, this, _isExcluded);
142
- /**
143
- *
144
- * @deprecated
145
- */
146
- _chunkYS56QITScjs.__privateAdd.call(void 0, this, _isIncluded);
147
- _chunkYS56QITScjs.__privateAdd.call(void 0, this, _methods);
148
- _chunkYS56QITScjs.__privateAdd.call(void 0, this, _operationsByMethod, {});
136
+ _chunkGWI26OTOcjs.__privateAdd.call(void 0, this, _OperationGenerator_instances);
137
+ _chunkGWI26OTOcjs.__privateAdd.call(void 0, this, _operationsByMethod, {});
149
138
  }
150
139
  get operationsByMethod() {
151
- return _chunkYS56QITScjs.__privateGet.call(void 0, this, _operationsByMethod);
140
+ return _chunkGWI26OTOcjs.__privateGet.call(void 0, this, _operationsByMethod);
152
141
  }
153
142
  set operationsByMethod(paths) {
154
- _chunkYS56QITScjs.__privateSet.call(void 0, this, _operationsByMethod, paths);
143
+ _chunkGWI26OTOcjs.__privateSet.call(void 0, this, _operationsByMethod, paths);
155
144
  }
156
- getSchemas(operation, forStatusCode) {
145
+ getSchemas(operation, { forStatusCode, resolveName = (name) => name } = {}) {
157
146
  const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
158
147
  const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
159
148
  const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
@@ -167,7 +156,7 @@ var OperationGenerator = class extends _core.Generator {
167
156
  }
168
157
  const schema = this.context.oas.getResponseSchema(operation, statusCode);
169
158
  return {
170
- name: _transformers2.default.pascalCase(`${operation.getOperationId()} ${name}`),
159
+ name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${name}`)),
171
160
  description: _optionalChain([operation, 'access', _7 => _7.getResponseByStatusCode, 'call', _8 => _8(statusCode), 'optionalAccess', _9 => _9.description]),
172
161
  schema,
173
162
  operation,
@@ -178,28 +167,28 @@ var OperationGenerator = class extends _core.Generator {
178
167
  });
179
168
  return {
180
169
  pathParams: pathParamsSchema ? {
181
- name: _transformers2.default.pascalCase(`${operation.getOperationId()} PathParams`),
170
+ name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} PathParams`)),
182
171
  operation,
183
172
  operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
184
173
  schema: pathParamsSchema,
185
174
  keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : void 0
186
175
  } : void 0,
187
176
  queryParams: queryParamsSchema ? {
188
- name: _transformers2.default.pascalCase(`${operation.getOperationId()} QueryParams`),
177
+ name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} QueryParams`)),
189
178
  operation,
190
179
  operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
191
180
  schema: queryParamsSchema,
192
181
  keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : []
193
182
  } : void 0,
194
183
  headerParams: headerParamsSchema ? {
195
- name: _transformers2.default.pascalCase(`${operation.getOperationId()} HeaderParams`),
184
+ name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} HeaderParams`)),
196
185
  operation,
197
186
  operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
198
187
  schema: headerParamsSchema,
199
188
  keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : void 0
200
189
  } : void 0,
201
190
  request: requestSchema ? {
202
- name: _transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`),
191
+ name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
203
192
  description: _optionalChain([operation, 'access', _11 => _11.schema, 'access', _12 => _12.requestBody, 'optionalAccess', _13 => _13.description]),
204
193
  operation,
205
194
  operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
@@ -211,7 +200,7 @@ var OperationGenerator = class extends _core.Generator {
211
200
  }) : void 0
212
201
  } : void 0,
213
202
  response: {
214
- name: _transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`),
203
+ name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
215
204
  description: _optionalChain([operation, 'access', _17 => _17.getResponseAsJSONSchema, 'call', _18 => _18(responseStatusCode), 'optionalAccess', _19 => _19.at, 'call', _20 => _20(0), 'optionalAccess', _21 => _21.description]),
216
205
  operation,
217
206
  operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
@@ -234,9 +223,9 @@ var OperationGenerator = class extends _core.Generator {
234
223
  const methods = Object.keys(method);
235
224
  methods.forEach((method2) => {
236
225
  const operation = oas.operation(path2, method2);
237
- if (operation && _chunkYS56QITScjs.__privateGet.call(void 0, this, _methods, methods_get)[method2]) {
238
- const isExcluded = _chunkYS56QITScjs.__privateMethod.call(void 0, this, _isExcluded, isExcluded_fn).call(this, operation, method2);
239
- const isIncluded = this.context.include ? _chunkYS56QITScjs.__privateMethod.call(void 0, this, _isIncluded, isIncluded_fn).call(this, operation, method2) : true;
226
+ if (operation && _chunkGWI26OTOcjs.__privateGet.call(void 0, this, _OperationGenerator_instances, methods_get)[method2]) {
227
+ const isExcluded = _chunkGWI26OTOcjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, isExcluded_fn).call(this, operation, method2);
228
+ const isIncluded = this.context.include ? _chunkGWI26OTOcjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, isIncluded_fn).call(this, operation, method2) : true;
240
229
  if (isIncluded && !isExcluded) {
241
230
  if (!acc[path2]) {
242
231
  acc[path2] = {};
@@ -257,8 +246,8 @@ var OperationGenerator = class extends _core.Generator {
257
246
  const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
258
247
  methods.forEach((method) => {
259
248
  const { operation } = _optionalChain([this, 'access', _37 => _37.operationsByMethod, 'access', _38 => _38[path2], 'optionalAccess', _39 => _39[method]]);
260
- const options = _chunkYS56QITScjs.__privateMethod.call(void 0, this, _getOptions, getOptions_fn).call(this, operation, method);
261
- const promiseMethod = _optionalChain([_chunkYS56QITScjs.__privateGet.call(void 0, this, _methods, methods_get), 'access', _40 => _40[method], 'optionalAccess', _41 => _41.call, 'call', _42 => _42(this, operation, {
249
+ const options = _chunkGWI26OTOcjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, getOptions_fn).call(this, operation, method);
250
+ const promiseMethod = _optionalChain([_chunkGWI26OTOcjs.__privateGet.call(void 0, this, _OperationGenerator_instances, methods_get), 'access', _40 => _40[method], 'optionalAccess', _41 => _41.call, 'call', _42 => _42(this, operation, {
262
251
  ...this.options,
263
252
  ...options
264
253
  })]);
@@ -324,7 +313,7 @@ var OperationGenerator = class extends _core.Generator {
324
313
  }
325
314
  };
326
315
  _operationsByMethod = new WeakMap();
327
- _getOptions = new WeakSet();
316
+ _OperationGenerator_instances = new WeakSet();
328
317
  getOptions_fn = function(operation, method) {
329
318
  const { override = [] } = this.context;
330
319
  return _optionalChain([override, 'access', _43 => _43.find, 'call', _44 => _44(({ pattern, type }) => {
@@ -343,7 +332,10 @@ getOptions_fn = function(operation, method) {
343
332
  return false;
344
333
  }), 'optionalAccess', _51 => _51.options]) || {};
345
334
  };
346
- _isExcluded = new WeakSet();
335
+ /**
336
+ *
337
+ * @deprecated
338
+ */
347
339
  isExcluded_fn = function(operation, method) {
348
340
  const { exclude = [] } = this.context;
349
341
  let matched = false;
@@ -363,7 +355,10 @@ isExcluded_fn = function(operation, method) {
363
355
  });
364
356
  return matched;
365
357
  };
366
- _isIncluded = new WeakSet();
358
+ /**
359
+ *
360
+ * @deprecated
361
+ */
367
362
  isIncluded_fn = function(operation, method) {
368
363
  const { include = [] } = this.context;
369
364
  let matched = false;
@@ -383,7 +378,6 @@ isIncluded_fn = function(operation, method) {
383
378
  });
384
379
  return matched;
385
380
  };
386
- _methods = new WeakSet();
387
381
  methods_get = function() {
388
382
  return {
389
383
  get: this.get,
@@ -408,5 +402,5 @@ var src_default = definePluginDefault;
408
402
 
409
403
 
410
404
 
411
- exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = _chunkUSWJ3LICcjs.SchemaGenerator; exports.default = src_default; exports.isKeyword = _chunkUSWJ3LICcjs.isKeyword; exports.pluginOas = pluginOas; exports.pluginOasName = pluginOasName; exports.schemaKeywords = _chunkUSWJ3LICcjs.schemaKeywords;
405
+ exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = _chunkERS2ZSATcjs.SchemaGenerator; exports.default = src_default; exports.isKeyword = _chunkERS2ZSATcjs.isKeyword; exports.pluginOas = pluginOas; exports.pluginOasName = pluginOasName; exports.schemaKeywords = _chunkERS2ZSATcjs.schemaKeywords;
412
406
  //# sourceMappingURL=index.cjs.map