@kubb/plugin-oas 3.0.0-alpha.15 → 3.0.0-alpha.16

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 (76) hide show
  1. package/dist/{OperationGenerator-BqfyX5-8.d.cts → OperationGenerator-B5CoXmjA.d.cts} +22 -20
  2. package/dist/{OperationGenerator-BqfyX5-8.d.ts → OperationGenerator-B5CoXmjA.d.ts} +22 -20
  3. package/dist/{Schema-BgpIlA79.d.cts → Schema-BsgDay0E.d.cts} +1 -12
  4. package/dist/{Schema-ExMIJOhD.d.ts → Schema-Dvt6i_X3.d.ts} +1 -12
  5. package/dist/chunk-2QECZEUD.js +76 -0
  6. package/dist/chunk-2QECZEUD.js.map +1 -0
  7. package/dist/chunk-4OQEPWOG.js +38 -0
  8. package/dist/chunk-4OQEPWOG.js.map +1 -0
  9. package/dist/chunk-7Q5B67MW.cjs +1110 -0
  10. package/dist/chunk-7Q5B67MW.cjs.map +1 -0
  11. package/dist/chunk-7XBQZ7AX.js +1098 -0
  12. package/dist/chunk-7XBQZ7AX.js.map +1 -0
  13. package/dist/{chunk-AAIEMW6V.cjs → chunk-CQDZGAA6.cjs} +28 -798
  14. package/dist/chunk-CQDZGAA6.cjs.map +1 -0
  15. package/dist/{chunk-M3V3WMCW.js → chunk-CYF724QJ.js} +11 -773
  16. package/dist/chunk-CYF724QJ.js.map +1 -0
  17. package/dist/{chunk-PZTS5YZV.js → chunk-D2N6LDLT.js} +15 -13
  18. package/dist/chunk-D2N6LDLT.js.map +1 -0
  19. package/dist/{chunk-I3ZL3GUQ.cjs → chunk-LCPCIS3S.cjs} +19 -17
  20. package/dist/chunk-LCPCIS3S.cjs.map +1 -0
  21. package/dist/chunk-PUFCST25.cjs +84 -0
  22. package/dist/chunk-PUFCST25.cjs.map +1 -0
  23. package/dist/chunk-TYQZ2BD7.cjs +42 -0
  24. package/dist/chunk-TYQZ2BD7.cjs.map +1 -0
  25. package/dist/components.cjs +5 -6
  26. package/dist/components.d.cts +2 -2
  27. package/dist/components.d.ts +2 -2
  28. package/dist/components.js +2 -3
  29. package/dist/generators.cjs +4 -5
  30. package/dist/generators.d.cts +1 -1
  31. package/dist/generators.d.ts +1 -1
  32. package/dist/generators.js +3 -4
  33. package/dist/hooks.cjs +102 -31
  34. package/dist/hooks.cjs.map +1 -1
  35. package/dist/hooks.d.cts +39 -6
  36. package/dist/hooks.d.ts +39 -6
  37. package/dist/hooks.js +92 -20
  38. package/dist/hooks.js.map +1 -1
  39. package/dist/index.cjs +25 -410
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +2 -2
  42. package/dist/index.d.ts +2 -2
  43. package/dist/index.js +5 -400
  44. package/dist/index.js.map +1 -1
  45. package/dist/utils.cjs +12 -12
  46. package/dist/utils.cjs.map +1 -1
  47. package/dist/utils.d.cts +2 -2
  48. package/dist/utils.d.ts +2 -2
  49. package/dist/utils.js +2 -3
  50. package/dist/utils.js.map +1 -1
  51. package/package.json +10 -10
  52. package/src/OperationGenerator.ts +11 -15
  53. package/src/SchemaGenerator.ts +14 -5
  54. package/src/components/Schema.tsx +1 -98
  55. package/src/generator.tsx +22 -14
  56. package/src/generators/jsonGenerator.ts +4 -4
  57. package/src/hooks/index.ts +2 -0
  58. package/src/hooks/useOperationManager.ts +76 -29
  59. package/src/hooks/useSchemaManager.ts +76 -0
  60. package/src/utils/getParams.ts +1 -1
  61. package/dist/chunk-2PMRS7PB.cjs +0 -8
  62. package/dist/chunk-2PMRS7PB.cjs.map +0 -1
  63. package/dist/chunk-2V64GHQ4.js +0 -32
  64. package/dist/chunk-2V64GHQ4.js.map +0 -1
  65. package/dist/chunk-4JIFKRM5.js +0 -6
  66. package/dist/chunk-4JIFKRM5.js.map +0 -1
  67. package/dist/chunk-5ULY3TQB.cjs +0 -90
  68. package/dist/chunk-5ULY3TQB.cjs.map +0 -1
  69. package/dist/chunk-AAIEMW6V.cjs.map +0 -1
  70. package/dist/chunk-CFU6KMOB.cjs +0 -38
  71. package/dist/chunk-CFU6KMOB.cjs.map +0 -1
  72. package/dist/chunk-GAPWY2CE.js +0 -84
  73. package/dist/chunk-GAPWY2CE.js.map +0 -1
  74. package/dist/chunk-I3ZL3GUQ.cjs.map +0 -1
  75. package/dist/chunk-M3V3WMCW.js.map +0 -1
  76. package/dist/chunk-PZTS5YZV.js.map +0 -1
package/dist/hooks.cjs CHANGED
@@ -1,16 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkAAIEMW6V_cjs = require('./chunk-AAIEMW6V.cjs');
4
- var chunk5ULY3TQB_cjs = require('./chunk-5ULY3TQB.cjs');
3
+ var chunk7Q5B67MW_cjs = require('./chunk-7Q5B67MW.cjs');
4
+ require('./chunk-PUFCST25.cjs');
5
+ require('./chunk-LCPCIS3S.cjs');
6
+ var chunkCQDZGAA6_cjs = require('./chunk-CQDZGAA6.cjs');
7
+ var chunkTYQZ2BD7_cjs = require('./chunk-TYQZ2BD7.cjs');
5
8
  var react = require('@kubb/react');
6
9
 
7
10
  // src/hooks/index.ts
8
- chunk5ULY3TQB_cjs.init_cjs_shims();
11
+ chunkTYQZ2BD7_cjs.init_cjs_shims();
9
12
 
10
13
  // src/hooks/useOas.ts
11
- chunk5ULY3TQB_cjs.init_cjs_shims();
14
+ chunkTYQZ2BD7_cjs.init_cjs_shims();
12
15
  function useOas() {
13
- const { oas } = react.useContext(chunkAAIEMW6V_cjs.Oas.Context);
16
+ const { oas } = react.useContext(chunkCQDZGAA6_cjs.Oas.Context);
14
17
  if (!oas) {
15
18
  throw new Error("Oas is not defined");
16
19
  }
@@ -18,9 +21,9 @@ function useOas() {
18
21
  }
19
22
 
20
23
  // src/hooks/useOperation.ts
21
- chunk5ULY3TQB_cjs.init_cjs_shims();
24
+ chunkTYQZ2BD7_cjs.init_cjs_shims();
22
25
  function useOperation() {
23
- const { operation } = react.useContext(chunkAAIEMW6V_cjs.Operation.Context);
26
+ const { operation } = react.useContext(chunkCQDZGAA6_cjs.Operation.Context);
24
27
  if (!operation) {
25
28
  throw new Error("Operation is not defined");
26
29
  }
@@ -28,23 +31,42 @@ function useOperation() {
28
31
  }
29
32
 
30
33
  // src/hooks/useOperationManager.ts
31
- chunk5ULY3TQB_cjs.init_cjs_shims();
34
+ chunkTYQZ2BD7_cjs.init_cjs_shims();
32
35
  function useOperationManager() {
33
36
  const { plugin, pluginManager } = react.useApp();
34
- const { generator } = react.useContext(chunkAAIEMW6V_cjs.Oas.Context);
35
- if (!generator) {
36
- throw new Error(`'generator' is not defined`);
37
- }
38
- const getName = (operation, { pluginKey = plugin.key, type }) => {
37
+ const { generator } = react.useContext(chunkCQDZGAA6_cjs.Oas.Context);
38
+ const getName = (operation, { prefix = "", suffix = "", pluginKey = plugin.key, type }) => {
39
39
  return pluginManager.resolveName({
40
- name: operation.getOperationId(),
40
+ name: `${prefix} ${operation.getOperationId()} ${suffix}`,
41
41
  pluginKey,
42
42
  type
43
43
  });
44
44
  };
45
- const getFile = (operation, { pluginKey = plugin.key, extName = ".ts" } = {}) => {
46
- const tag = operation.getTags().at(0)?.name;
47
- const name = getName(operation, { type: "file", pluginKey });
45
+ const getSchemas = (operation, params) => {
46
+ if (!generator) {
47
+ throw new Error(`'generator' is not defined`);
48
+ }
49
+ return generator.getSchemas(operation, {
50
+ resolveName: (name) => pluginManager.resolveName({
51
+ name,
52
+ pluginKey: params?.pluginKey,
53
+ type: params?.type
54
+ })
55
+ });
56
+ };
57
+ const getSchemaName = (operation, key, { pluginKey = plugin.key, type } = {}) => {
58
+ const schemas = getSchemas(operation);
59
+ if (!schemas[key]?.name) {
60
+ throw new Error(`SchemaName not found for ${operation.getOperationId()}`);
61
+ }
62
+ return pluginManager.resolveName({
63
+ name: schemas[key]?.name,
64
+ pluginKey,
65
+ type
66
+ });
67
+ };
68
+ const getFile = (operation, { prefix, suffix, pluginKey = plugin.key, tag = operation.getTags().at(0)?.name, extName = ".ts" } = {}) => {
69
+ const name = getName(operation, { type: "file", pluginKey, prefix, suffix });
48
70
  const file = pluginManager.getFile({
49
71
  name,
50
72
  extName,
@@ -62,6 +84,9 @@ function useOperationManager() {
62
84
  };
63
85
  };
64
86
  const groupSchemasByName = (operation, { pluginKey = plugin.key, type }) => {
87
+ if (!generator) {
88
+ throw new Error(`'generator' is not defined`);
89
+ }
65
90
  const schemas = generator.getSchemas(operation);
66
91
  const errors = (schemas.errors || []).reduce(
67
92
  (prev, acc) => {
@@ -119,22 +144,16 @@ function useOperationManager() {
119
144
  return {
120
145
  getName,
121
146
  getFile,
122
- getSchemas: (operation, params, forStatusCode) => generator.getSchemas(operation, {
123
- forStatusCode,
124
- resolveName: (name) => pluginManager.resolveName({
125
- name,
126
- pluginKey: params?.pluginKey,
127
- type: params?.type
128
- })
129
- }),
147
+ getSchemas,
148
+ getSchemaName,
130
149
  groupSchemasByName
131
150
  };
132
151
  }
133
152
 
134
153
  // src/hooks/useOperations.ts
135
- chunk5ULY3TQB_cjs.init_cjs_shims();
154
+ chunkTYQZ2BD7_cjs.init_cjs_shims();
136
155
  function useOperations({ method, path } = {}) {
137
- const { operations } = react.useContext(chunkAAIEMW6V_cjs.Oas.Context);
156
+ const { operations } = react.useContext(chunkCQDZGAA6_cjs.Oas.Context);
138
157
  if (!operations) {
139
158
  throw new Error("Operations is not defined");
140
159
  }
@@ -148,13 +167,65 @@ function useOperations({ method, path } = {}) {
148
167
  return items;
149
168
  }
150
169
 
151
- Object.defineProperty(exports, "useSchema", {
152
- enumerable: true,
153
- get: function () { return chunkAAIEMW6V_cjs.useSchema; }
154
- });
170
+ // src/hooks/useSchema.ts
171
+ chunkTYQZ2BD7_cjs.init_cjs_shims();
172
+ function useSchema() {
173
+ const props = react.useContext(chunkCQDZGAA6_cjs.Schema.Context);
174
+ return props;
175
+ }
176
+
177
+ // src/hooks/useSchemaManager.ts
178
+ chunkTYQZ2BD7_cjs.init_cjs_shims();
179
+ function useSchemaManager() {
180
+ const { mode, plugin, pluginManager, fileManager } = react.useApp();
181
+ const getName = (name, { pluginKey = plugin.key, type }) => {
182
+ return pluginManager.resolveName({
183
+ name,
184
+ pluginKey,
185
+ type
186
+ });
187
+ };
188
+ const getFile = (name, { mode: mode2 = "split", pluginKey = plugin.key, extName = ".ts", tag } = {}) => {
189
+ const resolvedName = mode2 === "single" ? "" : getName(name, { type: "file", pluginKey });
190
+ const file = pluginManager.getFile({
191
+ name: resolvedName,
192
+ extName,
193
+ pluginKey,
194
+ options: { type: "file", pluginKey, tag }
195
+ });
196
+ return {
197
+ ...file,
198
+ meta: {
199
+ ...file.meta,
200
+ name: resolvedName,
201
+ pluginKey
202
+ }
203
+ };
204
+ };
205
+ const getImports = (tree) => {
206
+ const refs = chunk7Q5B67MW_cjs.SchemaGenerator.deepSearch(tree, chunk7Q5B67MW_cjs.schemaKeywords.ref);
207
+ return refs?.map((item, i) => {
208
+ if (!item.args.path) {
209
+ return void 0;
210
+ }
211
+ return {
212
+ name: [item.args.name],
213
+ path: item.args.path
214
+ };
215
+ }).filter(Boolean);
216
+ };
217
+ return {
218
+ getName,
219
+ getFile,
220
+ getImports
221
+ };
222
+ }
223
+
155
224
  exports.useOas = useOas;
156
225
  exports.useOperation = useOperation;
157
226
  exports.useOperationManager = useOperationManager;
158
227
  exports.useOperations = useOperations;
228
+ exports.useSchema = useSchema;
229
+ exports.useSchemaManager = useSchemaManager;
159
230
  //# sourceMappingURL=hooks.cjs.map
160
231
  //# 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":["init_cjs_shims","useContext","Oas","Operation","useApp"],"mappings":";;;;;;;AAAAA,gCAAA,EAAA,CAAA;;;ACAAA,gCAAA,EAAA,CAAA;AAMO,SAAS,MAAkB,GAAA;AAChC,EAAA,MAAM,EAAE,GAAA,EAAQ,GAAAC,gBAAA,CAAWC,sBAAI,OAAO,CAAA,CAAA;AAEtC,EAAA,I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W,QAAQ,aAC9B,KAAA,SAAA,CAAU,WAAW,SAAW,EAAA;AAAA,MAC9B,aAAA;AAAA,MACA,WAAa,EAAA,CAAC,IACZ,KAAA,aAAA,CAAc,WAAY,CAAA;AAAA,QACxB,IAAA;AAAA,QACA,WAAW,MAAQ,EAAA,SAAA;AAAA,QACnB,MAAM,MAAQ,EAAA,IAAA;AAAA,OACf,CAAA;AAAA,KACJ,CAAA;AAAA,IACH,kBAAA;AAAA,GACF,CAAA;AACF,CAAA;;;ACnKAF,gCAAA,EAAA,CAAA;AAsBO,SAAS,cAAc,EAAE,MAAA,EAAQ,IAAK,EAAA,GAAwB,EAAiB,EAAA;AACpF,EAAA,MAAM,EAAE,UAAA,EAAeC,GAAAA,gBAAAA,CAAWC,sBAAI,OAAO,CAAA,CAAA;AAE7C,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAM,MAAA,IAAI,MAAM,2BAA2B,CAAA,CAAA;AAAA,GAC7C;AACA,EAAA,IAAI,KAAQ,GAAA,UAAA,CAAA;AAEZ,EAAA,IAAI,IAAM,EAAA;AACR,IAAA,KAAA,GAAQ,MAAM,MAAO,CAAA,CAAC,IAAS,KAAA,IAAA,CAAK,SAAS,IAAI,CAAA,CAAA;AAAA,GACnD;AAEA,EAAA,IAAI,MAAQ,EAAA;AACV,IAAA,KAAA,GAAQ,MAAM,MAAO,CAAA,CAAC,IAAS,KAAA,IAAA,CAAK,WAAW,MAAM,CAAA,CAAA;AAAA,GACvD;AAEA,EAAO,OAAA,KAAA,CAAA;AACT","file":"hooks.cjs","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"]}
1
+ {"version":3,"sources":["../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts","../src/hooks/useSchema.ts","../src/hooks/useSchemaManager.ts"],"names":["init_cjs_shims","useContext","Oas","Operation","useApp","Schema","mode","SchemaGenerator","schemaKeywords"],"mappings":";;;;;;;;;;AAAAA,gCAAA,EAAA,CAAA;;;ACAAA,gCAAA,EAAA,CAAA;AAMO,SAAS,MAAkB,GAAA;AAChC,EAAA,MAAM,EAAE,GAAA,EAAQ,GAAAC,gBAAA,CAAWC,sBAAI,OAAO,CAAA,CAAA;AAEtC,EAAA,IAAI,CAAC,GAAK,EAAA;AACR,IAAM,MAAA,IAAI,MAAM,oBAAoB,CAAA,CAAA;AAAA,GACtC;AAEA,EAAO,OAAA,GAAA,CAAA;AACT,CAAA;;;ACdAF,gCAAA,EAAA,CAAA;AASO,SAAS,YAA8B,GAAA;AAC5C,EAAA,MAAM,EAAE,SAAA,EAAcC,GAAAA,gBAAAA,CAAWE,4BAAU,OAAO,CAAA,CAAA;AAElD,EAAA,IAAI,CAAC,SAAW,EAAA;AACd,IAAM,MAAA,IAAI,MAAM,0BAA0B,CAAA,CAAA;AAAA,GAC5C;AAEA,EAAO,OAAA,SAAA,CAAA;AACT,CAAA;;;ACjBAH,gCAAA,EAAA,CAAA;AAmEO,SAAS,m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,IAAA;AAAA,MACH,IAAM,EAAA;AAAA,QACJ,GAAG,IAAK,CAAA,IAAA;AAAA,QACR,IAAM,EAAA,YAAA;AAAA,QACN,SAAA;AAAA,OACF;AAAA,KACF,CAAA;AAAA,GACF,CAAA;AAEA,EAAM,MAAA,UAAA,GAAmD,CAAC,IAAS,KAAA;AACjE,IAAA,MAAM,IAAO,GAAAC,iCAAA,CAAgB,UAAW,CAAA,IAAA,EAAMC,iCAAe,GAAG,CAAA,CAAA;AAEhE,IAAA,OAAO,IACH,EAAA,GAAA,CAAI,CAAC,IAAA,EAAM,CAAM,KAAA;AACjB,MAAI,IAAA,CAAC,IAAK,CAAA,IAAA,CAAK,IAAM,EAAA;AACnB,QAAO,OAAA,KAAA,CAAA,CAAA;AAAA,OACT;AAEA,MAAO,OAAA;AAAA,QACL,IAAM,EAAA,CAAC,IAAK,CAAA,IAAA,CAAK,IAAI,CAAA;AAAA,QACrB,IAAA,EAAM,KAAK,IAAK,CAAA,IAAA;AAAA,OAClB,CAAA;AAAA,KACD,CACA,CAAA,MAAA,CAAO,OAAO,CAAA,CAAA;AAAA,GACnB,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,OAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,GACF,CAAA;AACF","file":"hooks.cjs","sourcesContent":["export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport type { SchemaNames } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\nexport { useSchemaManager } from './useSchemaManager.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\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getSchemaName: (\n operation: Operation,\n key: keyof Omit<OperationSchemas, 'errors' | 'statusCodes'>,\n params?: {\n pluginKey?: Plugin['key']\n type?: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extName?: KubbFile.Extname\n tag?: string\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n}\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 const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getSchemaName: UseOperationManagerResult['getSchemaName'] = (operation, key, { pluginKey = plugin.key, type } = {}) => {\n const schemas = getSchemas(operation)\n\n if (!schemas[key]?.name) {\n throw new Error(`SchemaName not found for ${operation.getOperationId()}`)\n }\n\n return pluginManager.resolveName({\n name: schemas[key]?.name,\n pluginKey,\n type,\n })\n }\n //TODO replace tag with group\n const getFile: UseOperationManagerResult['getFile'] = (\n operation,\n { prefix, suffix, pluginKey = plugin.key, tag = operation.getTags().at(0)?.name, extName = '.ts' } = {},\n ) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\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 if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n 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,\n getSchemaName,\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","import { useContext } from '@kubb/react'\n\nimport { Schema } from '../components/Schema.tsx'\n\nimport type { SchemaContextProps } from '../components/Schema.tsx'\n\ntype UseSchemaResult = SchemaContextProps\n\n/**\n * `useSchema` will return the current `schema properties`\n */\nexport function useSchema(): UseSchemaResult {\n const props = useContext(Schema.Context)\n\n return props as UseSchemaResult\n}\n","import { File, useApp } from '@kubb/react'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Mode } from '@kubb/fs/types'\nimport { type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (name: string, params?: { pluginKey?: Plugin['key']; mode?: Mode; extName?: KubbFile.Extname; tag?: string }) => KubbFile.File<FileMeta>\n getImports: (tree: Array<Schema>) => Array<KubbFile.Import>\n}\n\n/**\n * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const { mode, plugin, pluginManager, fileManager } = useApp()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n //TODO replace tag with group\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extName = '.ts', tag } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extName,\n pluginKey,\n options: { type: 'file', pluginKey, tag },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n const getImports: UseSchemaManagerResult['getImports'] = (tree) => {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item, i) => {\n if (!item.args.path) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n }\n\n return {\n getName,\n getFile,\n getImports,\n }\n}\n"]}
package/dist/hooks.d.cts CHANGED
@@ -1,8 +1,9 @@
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 { w as OperationSchemas } from './OperationGenerator-BqfyX5-8.cjs';
5
- import { a as SchemaContextProps } from './Schema-BgpIlA79.cjs';
4
+ import { Mode } from '@kubb/fs/types';
5
+ import { w as OperationSchemas, g as Schema } from './OperationGenerator-B5CoXmjA.cjs';
6
+ import { a as SchemaContextProps } from './Schema-BsgDay0E.cjs';
6
7
  import '@kubb/react/types';
7
8
  import '@kubb/oas/parser';
8
9
  import 'react';
@@ -14,7 +15,7 @@ declare function useOas(): Oas;
14
15
  */
15
16
  declare function useOperation(): Operation;
16
17
 
17
- type FileMeta = FileMetaBase & {
18
+ type FileMeta$1 = FileMetaBase & {
18
19
  pluginKey: Plugin['key'];
19
20
  name: string;
20
21
  tag?: string;
@@ -33,13 +34,22 @@ type SchemaNames = {
33
34
  };
34
35
  type UseOperationManagerResult = {
35
36
  getName: (operation: Operation, params: {
37
+ prefix?: string;
38
+ suffix?: string;
36
39
  pluginKey?: Plugin['key'];
37
40
  type: ResolveNameParams['type'];
38
41
  }) => string;
42
+ getSchemaName: (operation: Operation, key: keyof Omit<OperationSchemas, 'errors' | 'statusCodes'>, params?: {
43
+ pluginKey?: Plugin['key'];
44
+ type?: ResolveNameParams['type'];
45
+ }) => string;
39
46
  getFile: (operation: Operation, params?: {
47
+ prefix?: string;
48
+ suffix?: string;
40
49
  pluginKey?: Plugin['key'];
41
50
  extName?: KubbFile.Extname;
42
- }) => KubbFile.File<FileMeta>;
51
+ tag?: string;
52
+ }) => KubbFile.File<FileMeta$1>;
43
53
  groupSchemasByName: (operation: Operation, params: {
44
54
  pluginKey?: Plugin['key'];
45
55
  type: ResolveNameParams['type'];
@@ -47,7 +57,7 @@ type UseOperationManagerResult = {
47
57
  getSchemas: (operation: Operation, params?: {
48
58
  pluginKey?: Plugin['key'];
49
59
  type?: ResolveNameParams['type'];
50
- }, forStatusCode?: string | number) => OperationSchemas;
60
+ }) => OperationSchemas;
51
61
  };
52
62
  /**
53
63
  * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.
@@ -77,4 +87,27 @@ type UseSchemaResult = SchemaContextProps;
77
87
  */
78
88
  declare function useSchema(): UseSchemaResult;
79
89
 
80
- export { useOas, useOperation, useOperationManager, useOperations, useSchema };
90
+ type FileMeta = FileMetaBase & {
91
+ pluginKey: Plugin['key'];
92
+ name: string;
93
+ tag?: string;
94
+ };
95
+ type UseSchemaManagerResult = {
96
+ getName: (name: string, params: {
97
+ pluginKey?: Plugin['key'];
98
+ type: ResolveNameParams['type'];
99
+ }) => string;
100
+ getFile: (name: string, params?: {
101
+ pluginKey?: Plugin['key'];
102
+ mode?: Mode;
103
+ extName?: KubbFile.Extname;
104
+ tag?: string;
105
+ }) => KubbFile.File<FileMeta>;
106
+ getImports: (tree: Array<Schema>) => Array<KubbFile.Import>;
107
+ };
108
+ /**
109
+ * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.
110
+ */
111
+ declare function useSchemaManager(): UseSchemaManagerResult;
112
+
113
+ export { type SchemaNames, useOas, useOperation, useOperationManager, useOperations, useSchema, useSchemaManager };
package/dist/hooks.d.ts CHANGED
@@ -1,8 +1,9 @@
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 { w as OperationSchemas } from './OperationGenerator-BqfyX5-8.js';
5
- import { a as SchemaContextProps } from './Schema-ExMIJOhD.js';
4
+ import { Mode } from '@kubb/fs/types';
5
+ import { w as OperationSchemas, g as Schema } from './OperationGenerator-B5CoXmjA.js';
6
+ import { a as SchemaContextProps } from './Schema-Dvt6i_X3.js';
6
7
  import '@kubb/react/types';
7
8
  import '@kubb/oas/parser';
8
9
  import 'react';
@@ -14,7 +15,7 @@ declare function useOas(): Oas;
14
15
  */
15
16
  declare function useOperation(): Operation;
16
17
 
17
- type FileMeta = FileMetaBase & {
18
+ type FileMeta$1 = FileMetaBase & {
18
19
  pluginKey: Plugin['key'];
19
20
  name: string;
20
21
  tag?: string;
@@ -33,13 +34,22 @@ type SchemaNames = {
33
34
  };
34
35
  type UseOperationManagerResult = {
35
36
  getName: (operation: Operation, params: {
37
+ prefix?: string;
38
+ suffix?: string;
36
39
  pluginKey?: Plugin['key'];
37
40
  type: ResolveNameParams['type'];
38
41
  }) => string;
42
+ getSchemaName: (operation: Operation, key: keyof Omit<OperationSchemas, 'errors' | 'statusCodes'>, params?: {
43
+ pluginKey?: Plugin['key'];
44
+ type?: ResolveNameParams['type'];
45
+ }) => string;
39
46
  getFile: (operation: Operation, params?: {
47
+ prefix?: string;
48
+ suffix?: string;
40
49
  pluginKey?: Plugin['key'];
41
50
  extName?: KubbFile.Extname;
42
- }) => KubbFile.File<FileMeta>;
51
+ tag?: string;
52
+ }) => KubbFile.File<FileMeta$1>;
43
53
  groupSchemasByName: (operation: Operation, params: {
44
54
  pluginKey?: Plugin['key'];
45
55
  type: ResolveNameParams['type'];
@@ -47,7 +57,7 @@ type UseOperationManagerResult = {
47
57
  getSchemas: (operation: Operation, params?: {
48
58
  pluginKey?: Plugin['key'];
49
59
  type?: ResolveNameParams['type'];
50
- }, forStatusCode?: string | number) => OperationSchemas;
60
+ }) => OperationSchemas;
51
61
  };
52
62
  /**
53
63
  * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.
@@ -77,4 +87,27 @@ type UseSchemaResult = SchemaContextProps;
77
87
  */
78
88
  declare function useSchema(): UseSchemaResult;
79
89
 
80
- export { useOas, useOperation, useOperationManager, useOperations, useSchema };
90
+ type FileMeta = FileMetaBase & {
91
+ pluginKey: Plugin['key'];
92
+ name: string;
93
+ tag?: string;
94
+ };
95
+ type UseSchemaManagerResult = {
96
+ getName: (name: string, params: {
97
+ pluginKey?: Plugin['key'];
98
+ type: ResolveNameParams['type'];
99
+ }) => string;
100
+ getFile: (name: string, params?: {
101
+ pluginKey?: Plugin['key'];
102
+ mode?: Mode;
103
+ extName?: KubbFile.Extname;
104
+ tag?: string;
105
+ }) => KubbFile.File<FileMeta>;
106
+ getImports: (tree: Array<Schema>) => Array<KubbFile.Import>;
107
+ };
108
+ /**
109
+ * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.
110
+ */
111
+ declare function useSchemaManager(): UseSchemaManagerResult;
112
+
113
+ export { type SchemaNames, useOas, useOperation, useOperationManager, useOperations, useSchema, useSchemaManager };
package/dist/hooks.js CHANGED
@@ -1,6 +1,8 @@
1
- import { Oas, Operation } from './chunk-M3V3WMCW.js';
2
- export { useSchema } from './chunk-M3V3WMCW.js';
3
- import { init_esm_shims } from './chunk-GAPWY2CE.js';
1
+ import { SchemaGenerator, schemaKeywords } from './chunk-7XBQZ7AX.js';
2
+ import './chunk-2QECZEUD.js';
3
+ import './chunk-D2N6LDLT.js';
4
+ import { Oas, Operation, Schema } from './chunk-CYF724QJ.js';
5
+ import { init_esm_shims } from './chunk-4OQEPWOG.js';
4
6
  import { useContext, useApp } from '@kubb/react';
5
7
 
6
8
  // src/hooks/index.ts
@@ -31,19 +33,38 @@ init_esm_shims();
31
33
  function useOperationManager() {
32
34
  const { plugin, pluginManager } = useApp();
33
35
  const { generator } = useContext(Oas.Context);
34
- if (!generator) {
35
- throw new Error(`'generator' is not defined`);
36
- }
37
- const getName = (operation, { pluginKey = plugin.key, type }) => {
36
+ const getName = (operation, { prefix = "", suffix = "", pluginKey = plugin.key, type }) => {
37
+ return pluginManager.resolveName({
38
+ name: `${prefix} ${operation.getOperationId()} ${suffix}`,
39
+ pluginKey,
40
+ type
41
+ });
42
+ };
43
+ const getSchemas = (operation, params) => {
44
+ if (!generator) {
45
+ throw new Error(`'generator' is not defined`);
46
+ }
47
+ return generator.getSchemas(operation, {
48
+ resolveName: (name) => pluginManager.resolveName({
49
+ name,
50
+ pluginKey: params?.pluginKey,
51
+ type: params?.type
52
+ })
53
+ });
54
+ };
55
+ const getSchemaName = (operation, key, { pluginKey = plugin.key, type } = {}) => {
56
+ const schemas = getSchemas(operation);
57
+ if (!schemas[key]?.name) {
58
+ throw new Error(`SchemaName not found for ${operation.getOperationId()}`);
59
+ }
38
60
  return pluginManager.resolveName({
39
- name: operation.getOperationId(),
61
+ name: schemas[key]?.name,
40
62
  pluginKey,
41
63
  type
42
64
  });
43
65
  };
44
- const getFile = (operation, { pluginKey = plugin.key, extName = ".ts" } = {}) => {
45
- const tag = operation.getTags().at(0)?.name;
46
- const name = getName(operation, { type: "file", pluginKey });
66
+ const getFile = (operation, { prefix, suffix, pluginKey = plugin.key, tag = operation.getTags().at(0)?.name, extName = ".ts" } = {}) => {
67
+ const name = getName(operation, { type: "file", pluginKey, prefix, suffix });
47
68
  const file = pluginManager.getFile({
48
69
  name,
49
70
  extName,
@@ -61,6 +82,9 @@ function useOperationManager() {
61
82
  };
62
83
  };
63
84
  const groupSchemasByName = (operation, { pluginKey = plugin.key, type }) => {
85
+ if (!generator) {
86
+ throw new Error(`'generator' is not defined`);
87
+ }
64
88
  const schemas = generator.getSchemas(operation);
65
89
  const errors = (schemas.errors || []).reduce(
66
90
  (prev, acc) => {
@@ -118,14 +142,8 @@ function useOperationManager() {
118
142
  return {
119
143
  getName,
120
144
  getFile,
121
- getSchemas: (operation, params, forStatusCode) => generator.getSchemas(operation, {
122
- forStatusCode,
123
- resolveName: (name) => pluginManager.resolveName({
124
- name,
125
- pluginKey: params?.pluginKey,
126
- type: params?.type
127
- })
128
- }),
145
+ getSchemas,
146
+ getSchemaName,
129
147
  groupSchemasByName
130
148
  };
131
149
  }
@@ -147,6 +165,60 @@ function useOperations({ method, path } = {}) {
147
165
  return items;
148
166
  }
149
167
 
150
- export { useOas, useOperation, useOperationManager, useOperations };
168
+ // src/hooks/useSchema.ts
169
+ init_esm_shims();
170
+ function useSchema() {
171
+ const props = useContext(Schema.Context);
172
+ return props;
173
+ }
174
+
175
+ // src/hooks/useSchemaManager.ts
176
+ init_esm_shims();
177
+ function useSchemaManager() {
178
+ const { mode, plugin, pluginManager, fileManager } = useApp();
179
+ const getName = (name, { pluginKey = plugin.key, type }) => {
180
+ return pluginManager.resolveName({
181
+ name,
182
+ pluginKey,
183
+ type
184
+ });
185
+ };
186
+ const getFile = (name, { mode: mode2 = "split", pluginKey = plugin.key, extName = ".ts", tag } = {}) => {
187
+ const resolvedName = mode2 === "single" ? "" : getName(name, { type: "file", pluginKey });
188
+ const file = pluginManager.getFile({
189
+ name: resolvedName,
190
+ extName,
191
+ pluginKey,
192
+ options: { type: "file", pluginKey, tag }
193
+ });
194
+ return {
195
+ ...file,
196
+ meta: {
197
+ ...file.meta,
198
+ name: resolvedName,
199
+ pluginKey
200
+ }
201
+ };
202
+ };
203
+ const getImports = (tree) => {
204
+ const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref);
205
+ return refs?.map((item, i) => {
206
+ if (!item.args.path) {
207
+ return void 0;
208
+ }
209
+ return {
210
+ name: [item.args.name],
211
+ path: item.args.path
212
+ };
213
+ }).filter(Boolean);
214
+ };
215
+ return {
216
+ getName,
217
+ getFile,
218
+ getImports
219
+ };
220
+ }
221
+
222
+ export { useOas, useOperation, useOperationManager, useOperations, useSchema, useSchemaManager };
151
223
  //# sourceMappingURL=hooks.js.map
152
224
  //# sourceMappingURL=hooks.js.map
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"],"names":["useContext"],"mappings":";;;;;;AAAA,cAAA,EAAA,CAAA;;;ACAA,cAAA,EAAA,CAAA;AAMO,SAAS,MAAkB,GAAA;AAChC,EAAA,MAAM,EAAE,GAAA,EAAQ,GAAA,UAAA,CAAW,IAAI,OAAO,CAAA,CAAA;AAEtC,EAAA,IAAI,CAAC,GAAK,EAAA;AACR,IAAM,MAAA,IAAI,MAAM,oBAAoB,CAAA,CAAA;AAAA,GACtC;AAEA,EAAO,OAAA,GAAA,CAAA;AACT,CAAA;;;ACdA,cAAA,EAAA,CAAA;AASO,SAAS,YAA8B,GAAA;AAC5C,EAAA,MAAM,EAAE,SAAA,EAAcA,GAAAA,UAAAA,CAAW,UAAU,OAAO,CAAA,CAAA;AAElD,EAAA,IAAI,CAAC,SAAW,EAAA;AACd,IAAM,MA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AAA,EAAA,CAAA;AAsBO,SAAS,cAAc,EAAE,MAAA,EAAQ,IAAK,EAAA,GAAwB,EAAiB,EAAA;AACpF,EAAA,MAAM,EAAE,UAAA,EAAeA,GAAAA,UAAAA,CAAW,IAAI,OAAO,CAAA,CAAA;AAE7C,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAM,MAAA,IAAI,MAAM,2BAA2B,CAAA,CAAA;AAAA,GAC7C;AACA,EAAA,IAAI,KAAQ,GAAA,UAAA,CAAA;AAEZ,EAAA,IAAI,IAAM,EAAA;AACR,IAAA,KAAA,GAAQ,MAAM,MAAO,CAAA,CAAC,IAAS,KAAA,IAAA,CAAK,SAAS,IAAI,CAAA,CAAA;AAAA,GACnD;AAEA,EAAA,IAAI,MAAQ,EAAA;AACV,IAAA,KAAA,GAAQ,MAAM,MAAO,CAAA,CAAC,IAAS,KAAA,IAAA,CAAK,WAAW,MAAM,CAAA,CAAA;AAAA,GACvD;AAEA,EAAO,OAAA,KAAA,CAAA;AACT","file":"hooks.js","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"]}
1
+ {"version":3,"sources":["../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts","../src/hooks/useSchema.ts","../src/hooks/useSchemaManager.ts"],"names":["useContext","useApp","mode"],"mappings":";;;;;;;;AAAA,cAAA,EAAA,CAAA;;;ACAA,cAAA,EAAA,CAAA;AAMO,SAAS,MAAkB,GAAA;AAChC,EAAA,MAAM,EAAE,GAAA,EAAQ,GAAA,UAAA,CAAW,IAAI,OAAO,CAAA,CAAA;AAEtC,EAAA,IAAI,CAAC,GAAK,EAAA;AACR,IAAM,MAAA,IAAI,MAAM,oBAAoB,CAAA,CAAA;AAAA,GACtC;AAEA,EAAO,OAAA,GAAA,CAAA;AACT,CAAA;;;ACdA,cAAA,EAAA,CAAA;AASO,SAAS,YAA8B,GAAA;AAC5C,EAAA,MAAM,EAAE,SAAA,EAAcA,GAAAA,UAAAA,CAAW,UAAU,OAAO,CAAA,CAAA;AAElD,EAAA,IAAI,CAAC,SAAW,EAAA;AACd,IAAM,MAAA,IAAI,MAAM,0BAA0B,CAAA,CAAA;AAAA,GAC5C;AAEA,EAAO,OAAA,SAAA,CAAA;AACT,CAAA;;;ACjBA,cAAA,EAAA,CAAA;AAmEO,SAAS,mBAAiD,GAAA;AAC/D,EAAA,MAAM,EAAE,MAAA,EAAQ,aAAc,EAAA,GAAI,MAAO,EAAA,CAAA;AACzC,EAAA,MAAM,EAAE,SAAA,EAAcA,GAAAA,UAAAA,CAAW,IAAI,OAAO,CAAA,CAAA;AAE5C,EAAA,MAAM,OAAgD,GAAA,CAAC,SAAW,EAAA,EAAE,MAAS,GAAA,EAAA,EAAI,MAAS,GAAA,EAAA,EAAI,SAAY,GAAA,MAAA,CAAO,GAAK,EAAA,IAAA,EAAW,KAAA;AAC/H,IAAA,OAAO,cAAc,WAAY,CAAA;AAAA,MAC/B,IAAA,EAAM,GAA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AAK,IAAM,EAAA;AACnB,QAAO,OAAA,KAAA,CAAA,CAAA;AAAA,OACT;AAEA,MAAO,OAAA;AAAA,QACL,IAAM,EAAA,CAAC,IAAK,CAAA,IAAA,CAAK,IAAI,CAAA;AAAA,QACrB,IAAA,EAAM,KAAK,IAAK,CAAA,IAAA;AAAA,OAClB,CAAA;AAAA,KACD,CACA,CAAA,MAAA,CAAO,OAAO,CAAA,CAAA;AAAA,GACnB,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,OAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,GACF,CAAA;AACF","file":"hooks.js","sourcesContent":["export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport type { SchemaNames } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\nexport { useSchemaManager } from './useSchemaManager.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\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getSchemaName: (\n operation: Operation,\n key: keyof Omit<OperationSchemas, 'errors' | 'statusCodes'>,\n params?: {\n pluginKey?: Plugin['key']\n type?: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extName?: KubbFile.Extname\n tag?: string\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n}\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 const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getSchemaName: UseOperationManagerResult['getSchemaName'] = (operation, key, { pluginKey = plugin.key, type } = {}) => {\n const schemas = getSchemas(operation)\n\n if (!schemas[key]?.name) {\n throw new Error(`SchemaName not found for ${operation.getOperationId()}`)\n }\n\n return pluginManager.resolveName({\n name: schemas[key]?.name,\n pluginKey,\n type,\n })\n }\n //TODO replace tag with group\n const getFile: UseOperationManagerResult['getFile'] = (\n operation,\n { prefix, suffix, pluginKey = plugin.key, tag = operation.getTags().at(0)?.name, extName = '.ts' } = {},\n ) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\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 if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n 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,\n getSchemaName,\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","import { useContext } from '@kubb/react'\n\nimport { Schema } from '../components/Schema.tsx'\n\nimport type { SchemaContextProps } from '../components/Schema.tsx'\n\ntype UseSchemaResult = SchemaContextProps\n\n/**\n * `useSchema` will return the current `schema properties`\n */\nexport function useSchema(): UseSchemaResult {\n const props = useContext(Schema.Context)\n\n return props as UseSchemaResult\n}\n","import { File, useApp } from '@kubb/react'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Mode } from '@kubb/fs/types'\nimport { type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (name: string, params?: { pluginKey?: Plugin['key']; mode?: Mode; extName?: KubbFile.Extname; tag?: string }) => KubbFile.File<FileMeta>\n getImports: (tree: Array<Schema>) => Array<KubbFile.Import>\n}\n\n/**\n * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const { mode, plugin, pluginManager, fileManager } = useApp()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n //TODO replace tag with group\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extName = '.ts', tag } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extName,\n pluginKey,\n options: { type: 'file', pluginKey, tag },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n const getImports: UseSchemaManagerResult['getImports'] = (tree) => {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item, i) => {\n if (!item.args.path) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n }\n\n return {\n getName,\n getFile,\n getImports,\n }\n}\n"]}