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

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 (64) hide show
  1. package/dist/OperationGenerator-BqfyX5-8.d.cts +554 -0
  2. package/dist/OperationGenerator-BqfyX5-8.d.ts +554 -0
  3. package/dist/{Schema-B1vcPGiK.d.ts → Schema-BgpIlA79.d.cts} +2 -2
  4. package/dist/{Schema-DoSFh7Qd.d.cts → Schema-ExMIJOhD.d.ts} +2 -2
  5. package/dist/chunk-2PMRS7PB.cjs +8 -0
  6. package/dist/{chunk-KW7GCBTZ.cjs.map → chunk-2PMRS7PB.cjs.map} +1 -1
  7. package/dist/{chunk-TEEWKGS3.js → chunk-2V64GHQ4.js} +3 -3
  8. package/dist/{chunk-TEEWKGS3.js.map → chunk-2V64GHQ4.js.map} +1 -1
  9. package/dist/chunk-4JIFKRM5.js +6 -0
  10. package/dist/{chunk-N3GACHZX.js.map → chunk-4JIFKRM5.js.map} +1 -1
  11. package/dist/{chunk-JRZ3YURA.cjs → chunk-5ULY3TQB.cjs} +4 -4
  12. package/dist/{chunk-JRZ3YURA.cjs.map → chunk-5ULY3TQB.cjs.map} +1 -1
  13. package/dist/{chunk-FFFMYESV.cjs → chunk-AAIEMW6V.cjs} +27 -27
  14. package/dist/chunk-AAIEMW6V.cjs.map +1 -0
  15. package/dist/{chunk-G35AGMCZ.cjs → chunk-CFU6KMOB.cjs} +4 -4
  16. package/dist/{chunk-G35AGMCZ.cjs.map → chunk-CFU6KMOB.cjs.map} +1 -1
  17. package/dist/{chunk-NW6726BC.js → chunk-GAPWY2CE.js} +4 -4
  18. package/dist/{chunk-NW6726BC.js.map → chunk-GAPWY2CE.js.map} +1 -1
  19. package/dist/chunk-I3ZL3GUQ.cjs +97 -0
  20. package/dist/chunk-I3ZL3GUQ.cjs.map +1 -0
  21. package/dist/{chunk-5QUCRUOD.js → chunk-M3V3WMCW.js} +4 -4
  22. package/dist/chunk-M3V3WMCW.js.map +1 -0
  23. package/dist/chunk-PZTS5YZV.js +93 -0
  24. package/dist/chunk-PZTS5YZV.js.map +1 -0
  25. package/dist/components.cjs +6 -6
  26. package/dist/components.d.cts +3 -5
  27. package/dist/components.d.ts +3 -5
  28. package/dist/components.js +3 -3
  29. package/dist/generators.cjs +15 -0
  30. package/dist/generators.cjs.map +1 -0
  31. package/dist/generators.d.cts +10 -0
  32. package/dist/generators.d.ts +10 -0
  33. package/dist/generators.js +6 -0
  34. package/dist/generators.js.map +1 -0
  35. package/dist/hooks.cjs +12 -12
  36. package/dist/hooks.d.cts +3 -4
  37. package/dist/hooks.d.ts +3 -4
  38. package/dist/hooks.js +3 -3
  39. package/dist/index.cjs +69 -100
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +2 -4
  42. package/dist/index.d.ts +2 -4
  43. package/dist/index.js +57 -93
  44. package/dist/index.js.map +1 -1
  45. package/dist/utils.cjs +9 -9
  46. package/dist/utils.d.cts +2 -2
  47. package/dist/utils.d.ts +2 -2
  48. package/dist/utils.js +3 -3
  49. package/package.json +18 -10
  50. package/src/components/Schema.tsx +1 -2
  51. package/src/generators/index.ts +1 -0
  52. package/src/generators/jsonGenerator.ts +30 -0
  53. package/src/plugin.ts +63 -43
  54. package/src/types.ts +23 -12
  55. package/dist/OperationGenerator-By5WOmWB.d.ts +0 -165
  56. package/dist/OperationGenerator-Gd1X7wUz.d.cts +0 -165
  57. package/dist/SchemaMapper-sGcY1xL5.d.cts +0 -247
  58. package/dist/SchemaMapper-sGcY1xL5.d.ts +0 -247
  59. package/dist/chunk-5QUCRUOD.js.map +0 -1
  60. package/dist/chunk-FFFMYESV.cjs.map +0 -1
  61. package/dist/chunk-KW7GCBTZ.cjs +0 -8
  62. package/dist/chunk-N3GACHZX.js +0 -6
  63. package/dist/types-CZTUCaE5.d.cts +0 -145
  64. package/dist/types-CZTUCaE5.d.ts +0 -145
@@ -0,0 +1,93 @@
1
+ import { require_jsx_runtime, Oas } from './chunk-M3V3WMCW.js';
2
+ import { init_esm_shims, __toESM } from './chunk-GAPWY2CE.js';
3
+ import { camelCase } from '@kubb/core/transformers';
4
+ import { createRoot, App } from '@kubb/react';
5
+
6
+ // src/generators/index.ts
7
+ init_esm_shims();
8
+
9
+ // src/generators/jsonGenerator.ts
10
+ init_esm_shims();
11
+
12
+ // src/generator.tsx
13
+ init_esm_shims();
14
+ var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
15
+ function createGenerator(parseOptions) {
16
+ return parseOptions;
17
+ }
18
+ function createReactGenerator(parseOptions) {
19
+ return {
20
+ ...parseOptions,
21
+ async operations({ instance, options, operations, operationsByMethod }) {
22
+ if (!parseOptions.Operations) {
23
+ return [];
24
+ }
25
+ const { pluginManager, oas, plugin, mode } = instance.context;
26
+ const root = createRoot({
27
+ logger: pluginManager.logger
28
+ });
29
+ root.render(
30
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operations, { operations, instance, operationsByMethod, options }) }) })
31
+ );
32
+ return root.files;
33
+ },
34
+ async operation({ instance, operation, options }) {
35
+ if (!parseOptions.Operation) {
36
+ return [];
37
+ }
38
+ const { pluginManager, oas, plugin, mode } = instance.context;
39
+ const root = createRoot({
40
+ logger: pluginManager.logger
41
+ });
42
+ root.render(
43
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operation, { operation, options, instance }) }) }) })
44
+ );
45
+ return root.files;
46
+ },
47
+ async schema({ instance, schema, name, options }) {
48
+ if (!parseOptions.Schema) {
49
+ return [];
50
+ }
51
+ const { pluginManager, oas, plugin, mode } = instance.context;
52
+ const root = createRoot({
53
+ logger: pluginManager.logger
54
+ });
55
+ const tree = instance.parse({ schema, name });
56
+ root.render(
57
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Schema, { schema, options, instance, name }) }) }) })
58
+ );
59
+ return root.files;
60
+ }
61
+ };
62
+ }
63
+
64
+ // src/generators/jsonGenerator.ts
65
+ var jsonGenerator = createGenerator({
66
+ name: "plugin-oas",
67
+ async schema({ schema, name, instance }) {
68
+ const { pluginManager, plugin } = instance.context;
69
+ const file = pluginManager.getFile({
70
+ name: camelCase(name),
71
+ extName: ".json",
72
+ mode: "split",
73
+ pluginKey: plugin.key
74
+ });
75
+ return [
76
+ {
77
+ ...file,
78
+ sources: [
79
+ {
80
+ name: camelCase(name),
81
+ isExportable: false,
82
+ isIndexable: false,
83
+ value: JSON.stringify(schema)
84
+ }
85
+ ]
86
+ }
87
+ ];
88
+ }
89
+ });
90
+
91
+ export { createGenerator, createReactGenerator, jsonGenerator };
92
+ //# sourceMappingURL=chunk-PZTS5YZV.js.map
93
+ //# sourceMappingURL=chunk-PZTS5YZV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generators/index.ts","../src/generators/jsonGenerator.ts","../src/generator.tsx"],"names":[],"mappings":";;;;;;AAAA,cAAA,EAAA,CAAA;;;ACAA,cAAA,EAAA,CAAA;;;ACAA,cAAA,EAAA,CAAA;AAsEY,IAAA,kBAAA,GAAA,OAAA,CAAA,mBAAA,EAAA,EAAA,CAAA,CAAA,CAAA;AA/BL,SAAS,gBAAuD,YAA+D,EAAA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elCase } from '@kubb/core/transformers'\nimport { createGenerator } from '../generator.tsx'\nimport type { PluginOas } from '../types.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, name, instance }) {\n const { pluginManager, plugin } = instance.context\n const file = pluginManager.getFile({\n name: camelCase(name),\n extName: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema),\n },\n ],\n },\n ]\n },\n})\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { OperationsByMethod } from './types.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n operationsByMethod: OperationsByMethod\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n name: string\n schema: SchemaObject\n options: TOptions['resolvedOptions']\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (props: OperationsProps<TOptions>) => KubbNode\n Operation?: (props: OperationProps<TOptions>) => KubbNode\n Schema?: (props: SchemaProps<TOptions>) => KubbNode\n /**\n * Combine all react nodes and only render ones(to string or render)\n */\n render?: () => any\n}\n\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations, operationsByMethod }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <parseOptions.Operations operations={operations} instance={instance} operationsByMethod={operationsByMethod} options={options} />\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <parseOptions.Operation operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async schema({ instance, schema, name, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const tree = instance.parse({ schema, name })\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={name} value={schema} tree={tree}>\n <parseOptions.Schema schema={schema} options={options} instance={instance} name={name} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n }\n}\n"]}
@@ -1,22 +1,22 @@
1
1
  'use strict';
2
2
 
3
- require('./chunk-KW7GCBTZ.cjs');
4
- var chunkFFFMYESV_cjs = require('./chunk-FFFMYESV.cjs');
5
- require('./chunk-JRZ3YURA.cjs');
3
+ require('./chunk-2PMRS7PB.cjs');
4
+ var chunkAAIEMW6V_cjs = require('./chunk-AAIEMW6V.cjs');
5
+ require('./chunk-5ULY3TQB.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, "Oas", {
10
10
  enumerable: true,
11
- get: function () { return chunkFFFMYESV_cjs.Oas; }
11
+ get: function () { return chunkAAIEMW6V_cjs.Oas; }
12
12
  });
13
13
  Object.defineProperty(exports, "Operation", {
14
14
  enumerable: true,
15
- get: function () { return chunkFFFMYESV_cjs.Operation; }
15
+ get: function () { return chunkAAIEMW6V_cjs.Operation; }
16
16
  });
17
17
  Object.defineProperty(exports, "Schema", {
18
18
  enumerable: true,
19
- get: function () { return chunkFFFMYESV_cjs.Schema; }
19
+ get: function () { return chunkAAIEMW6V_cjs.Schema; }
20
20
  });
21
21
  //# sourceMappingURL=components.cjs.map
22
22
  //# sourceMappingURL=components.cjs.map
@@ -1,12 +1,10 @@
1
- import { S as Schema } from './Schema-DoSFh7Qd.cjs';
1
+ import { S as Schema } from './Schema-BgpIlA79.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/types';
5
- import { a as OperationGenerator } from './OperationGenerator-Gd1X7wUz.cjs';
6
- import './SchemaMapper-sGcY1xL5.cjs';
7
- import '@kubb/fs/types';
5
+ import { b as OperationGenerator } from './OperationGenerator-BqfyX5-8.cjs';
8
6
  import '@kubb/core';
9
- import './types-CZTUCaE5.cjs';
7
+ import '@kubb/fs/types';
10
8
  import '@kubb/oas/parser';
11
9
 
12
10
  type Props$1 = {
@@ -1,12 +1,10 @@
1
- import { S as Schema } from './Schema-B1vcPGiK.js';
1
+ import { S as Schema } from './Schema-ExMIJOhD.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/types';
5
- import { a as OperationGenerator } from './OperationGenerator-By5WOmWB.js';
6
- import './SchemaMapper-sGcY1xL5.js';
7
- import '@kubb/fs/types';
5
+ import { b as OperationGenerator } from './OperationGenerator-BqfyX5-8.js';
8
6
  import '@kubb/core';
9
- import './types-CZTUCaE5.js';
7
+ import '@kubb/fs/types';
10
8
  import '@kubb/oas/parser';
11
9
 
12
10
  type Props$1 = {
@@ -1,5 +1,5 @@
1
- import './chunk-N3GACHZX.js';
2
- export { Oas, Operation, Schema } from './chunk-5QUCRUOD.js';
3
- import './chunk-NW6726BC.js';
1
+ import './chunk-4JIFKRM5.js';
2
+ export { Oas, Operation, Schema } from './chunk-M3V3WMCW.js';
3
+ import './chunk-GAPWY2CE.js';
4
4
  //# sourceMappingURL=components.js.map
5
5
  //# sourceMappingURL=components.js.map
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var chunkI3ZL3GUQ_cjs = require('./chunk-I3ZL3GUQ.cjs');
4
+ require('./chunk-2PMRS7PB.cjs');
5
+ require('./chunk-AAIEMW6V.cjs');
6
+ require('./chunk-5ULY3TQB.cjs');
7
+
8
+
9
+
10
+ Object.defineProperty(exports, "jsonGenerator", {
11
+ enumerable: true,
12
+ get: function () { return chunkI3ZL3GUQ_cjs.jsonGenerator; }
13
+ });
14
+ //# sourceMappingURL=generators.cjs.map
15
+ //# sourceMappingURL=generators.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.cjs"}
@@ -0,0 +1,10 @@
1
+ import { o as Generator, P as PluginOas } from './OperationGenerator-BqfyX5-8.cjs';
2
+ import '@kubb/core';
3
+ import '@kubb/fs/types';
4
+ import '@kubb/oas';
5
+ import '@kubb/react/types';
6
+ import '@kubb/oas/parser';
7
+
8
+ declare const jsonGenerator: Generator<PluginOas>;
9
+
10
+ export { jsonGenerator };
@@ -0,0 +1,10 @@
1
+ import { o as Generator, P as PluginOas } from './OperationGenerator-BqfyX5-8.js';
2
+ import '@kubb/core';
3
+ import '@kubb/fs/types';
4
+ import '@kubb/oas';
5
+ import '@kubb/react/types';
6
+ import '@kubb/oas/parser';
7
+
8
+ declare const jsonGenerator: Generator<PluginOas>;
9
+
10
+ export { jsonGenerator };
@@ -0,0 +1,6 @@
1
+ export { jsonGenerator } from './chunk-PZTS5YZV.js';
2
+ import './chunk-4JIFKRM5.js';
3
+ import './chunk-M3V3WMCW.js';
4
+ import './chunk-GAPWY2CE.js';
5
+ //# sourceMappingURL=generators.js.map
6
+ //# sourceMappingURL=generators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
package/dist/hooks.cjs CHANGED
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkFFFMYESV_cjs = require('./chunk-FFFMYESV.cjs');
4
- var chunkJRZ3YURA_cjs = require('./chunk-JRZ3YURA.cjs');
3
+ var chunkAAIEMW6V_cjs = require('./chunk-AAIEMW6V.cjs');
4
+ var chunk5ULY3TQB_cjs = require('./chunk-5ULY3TQB.cjs');
5
5
  var react = require('@kubb/react');
6
6
 
7
7
  // src/hooks/index.ts
8
- chunkJRZ3YURA_cjs.init_cjs_shims();
8
+ chunk5ULY3TQB_cjs.init_cjs_shims();
9
9
 
10
10
  // src/hooks/useOas.ts
11
- chunkJRZ3YURA_cjs.init_cjs_shims();
11
+ chunk5ULY3TQB_cjs.init_cjs_shims();
12
12
  function useOas() {
13
- const { oas } = react.useContext(chunkFFFMYESV_cjs.Oas.Context);
13
+ const { oas } = react.useContext(chunkAAIEMW6V_cjs.Oas.Context);
14
14
  if (!oas) {
15
15
  throw new Error("Oas is not defined");
16
16
  }
@@ -18,9 +18,9 @@ function useOas() {
18
18
  }
19
19
 
20
20
  // src/hooks/useOperation.ts
21
- chunkJRZ3YURA_cjs.init_cjs_shims();
21
+ chunk5ULY3TQB_cjs.init_cjs_shims();
22
22
  function useOperation() {
23
- const { operation } = react.useContext(chunkFFFMYESV_cjs.Operation.Context);
23
+ const { operation } = react.useContext(chunkAAIEMW6V_cjs.Operation.Context);
24
24
  if (!operation) {
25
25
  throw new Error("Operation is not defined");
26
26
  }
@@ -28,10 +28,10 @@ function useOperation() {
28
28
  }
29
29
 
30
30
  // src/hooks/useOperationManager.ts
31
- chunkJRZ3YURA_cjs.init_cjs_shims();
31
+ chunk5ULY3TQB_cjs.init_cjs_shims();
32
32
  function useOperationManager() {
33
33
  const { plugin, pluginManager } = react.useApp();
34
- const { generator } = react.useContext(chunkFFFMYESV_cjs.Oas.Context);
34
+ const { generator } = react.useContext(chunkAAIEMW6V_cjs.Oas.Context);
35
35
  if (!generator) {
36
36
  throw new Error(`'generator' is not defined`);
37
37
  }
@@ -132,9 +132,9 @@ function useOperationManager() {
132
132
  }
133
133
 
134
134
  // src/hooks/useOperations.ts
135
- chunkJRZ3YURA_cjs.init_cjs_shims();
135
+ chunk5ULY3TQB_cjs.init_cjs_shims();
136
136
  function useOperations({ method, path } = {}) {
137
- const { operations } = react.useContext(chunkFFFMYESV_cjs.Oas.Context);
137
+ const { operations } = react.useContext(chunkAAIEMW6V_cjs.Oas.Context);
138
138
  if (!operations) {
139
139
  throw new Error("Operations is not defined");
140
140
  }
@@ -150,7 +150,7 @@ function useOperations({ method, path } = {}) {
150
150
 
151
151
  Object.defineProperty(exports, "useSchema", {
152
152
  enumerable: true,
153
- get: function () { return chunkFFFMYESV_cjs.useSchema; }
153
+ get: function () { return chunkAAIEMW6V_cjs.useSchema; }
154
154
  });
155
155
  exports.useOas = useOas;
156
156
  exports.useOperation = useOperation;
package/dist/hooks.d.cts CHANGED
@@ -1,12 +1,11 @@
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 { e as OperationSchemas } from './types-CZTUCaE5.cjs';
5
- import { a as SchemaContextProps } from './Schema-DoSFh7Qd.cjs';
4
+ import { w as OperationSchemas } from './OperationGenerator-BqfyX5-8.cjs';
5
+ import { a as SchemaContextProps } from './Schema-BgpIlA79.cjs';
6
+ import '@kubb/react/types';
6
7
  import '@kubb/oas/parser';
7
8
  import 'react';
8
- import '@kubb/react/types';
9
- import './SchemaMapper-sGcY1xL5.cjs';
10
9
 
11
10
  declare function useOas(): Oas;
12
11
 
package/dist/hooks.d.ts CHANGED
@@ -1,12 +1,11 @@
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 { e as OperationSchemas } from './types-CZTUCaE5.js';
5
- import { a as SchemaContextProps } from './Schema-B1vcPGiK.js';
4
+ import { w as OperationSchemas } from './OperationGenerator-BqfyX5-8.js';
5
+ import { a as SchemaContextProps } from './Schema-ExMIJOhD.js';
6
+ import '@kubb/react/types';
6
7
  import '@kubb/oas/parser';
7
8
  import 'react';
8
- import '@kubb/react/types';
9
- import './SchemaMapper-sGcY1xL5.js';
10
9
 
11
10
  declare function useOas(): Oas;
12
11
 
package/dist/hooks.js CHANGED
@@ -1,6 +1,6 @@
1
- import { Oas, Operation } from './chunk-5QUCRUOD.js';
2
- export { useSchema } from './chunk-5QUCRUOD.js';
3
- import { init_esm_shims } from './chunk-NW6726BC.js';
1
+ import { Oas, Operation } from './chunk-M3V3WMCW.js';
2
+ export { useSchema } from './chunk-M3V3WMCW.js';
3
+ import { init_esm_shims } from './chunk-GAPWY2CE.js';
4
4
  import { useContext, useApp } from '@kubb/react';
5
5
 
6
6
  // src/hooks/index.ts
package/dist/index.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkG35AGMCZ_cjs = require('./chunk-G35AGMCZ.cjs');
4
- require('./chunk-KW7GCBTZ.cjs');
5
- var chunkFFFMYESV_cjs = require('./chunk-FFFMYESV.cjs');
6
- var chunkJRZ3YURA_cjs = require('./chunk-JRZ3YURA.cjs');
3
+ var chunkCFU6KMOB_cjs = require('./chunk-CFU6KMOB.cjs');
4
+ var chunkI3ZL3GUQ_cjs = require('./chunk-I3ZL3GUQ.cjs');
5
+ require('./chunk-2PMRS7PB.cjs');
6
+ var chunkAAIEMW6V_cjs = require('./chunk-AAIEMW6V.cjs');
7
+ var chunk5ULY3TQB_cjs = require('./chunk-5ULY3TQB.cjs');
7
8
  var core = require('@kubb/core');
8
9
  var transformers = require('@kubb/core/transformers');
9
10
  var path = require('path');
10
- var react = require('@kubb/react');
11
11
 
12
12
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
13
 
@@ -15,10 +15,10 @@ var transformers__default = /*#__PURE__*/_interopDefault(transformers);
15
15
  var path__default = /*#__PURE__*/_interopDefault(path);
16
16
 
17
17
  // src/index.ts
18
- chunkJRZ3YURA_cjs.init_cjs_shims();
18
+ chunk5ULY3TQB_cjs.init_cjs_shims();
19
19
 
20
20
  // src/OperationGenerator.ts
21
- chunkJRZ3YURA_cjs.init_cjs_shims();
21
+ chunk5ULY3TQB_cjs.init_cjs_shims();
22
22
  var OperationGenerator = class extends core.BaseGenerator {
23
23
  #operationsByMethod = {};
24
24
  get operationsByMethod() {
@@ -294,21 +294,26 @@ var OperationGenerator = class extends core.BaseGenerator {
294
294
  };
295
295
 
296
296
  // src/plugin.ts
297
- chunkJRZ3YURA_cjs.init_cjs_shims();
297
+ chunk5ULY3TQB_cjs.init_cjs_shims();
298
298
  var pluginOasName = "plugin-oas";
299
299
  var pluginOas = core.createPlugin((options) => {
300
300
  const {
301
- output = { path: "schemas", export: false },
301
+ output = {
302
+ path: "schemas",
303
+ export: false,
304
+ exportType: "barrelNamed"
305
+ },
302
306
  experimentalFilter: filter,
303
307
  experimentalSort: sort,
304
308
  validate = true,
309
+ generators = [chunkI3ZL3GUQ_cjs.jsonGenerator],
305
310
  serverIndex = 0,
306
311
  contentType,
307
312
  oasClass
308
313
  } = options;
309
314
  const getOas = async ({ config, logger, formatOptions }) => {
310
315
  try {
311
- const oas = await chunkG35AGMCZ_cjs.parseFromConfig(config, formatOptions, oasClass);
316
+ const oas = await chunkCFU6KMOB_cjs.parseFromConfig(config, formatOptions, oasClass);
312
317
  if (validate) {
313
318
  await oas.valdiate();
314
319
  }
@@ -316,18 +321,12 @@ var pluginOas = core.createPlugin((options) => {
316
321
  } catch (e) {
317
322
  const error = e;
318
323
  logger.emit("warning", error?.message);
319
- return chunkG35AGMCZ_cjs.parseFromConfig(config, {}, oasClass);
324
+ return chunkCFU6KMOB_cjs.parseFromConfig(config, {}, oasClass);
320
325
  }
321
326
  };
322
327
  return {
323
328
  name: pluginOasName,
324
- output: output === false ? {
325
- path: "",
326
- exportType: false
327
- } : {
328
- exportType: "barrelNamed",
329
- ...output
330
- },
329
+ output,
331
330
  options,
332
331
  context() {
333
332
  const { config, logger } = this;
@@ -337,16 +336,23 @@ var pluginOas = core.createPlugin((options) => {
337
336
  },
338
337
  async getSchemas({ includes } = {}) {
339
338
  const oas = await this.getOas();
340
- return chunkJRZ3YURA_cjs.getSchemas({ oas, contentType, includes });
339
+ return chunk5ULY3TQB_cjs.getSchemas({ oas, contentType, includes });
341
340
  },
342
341
  async getBaseURL() {
343
342
  const oasInstance = await this.getOas();
344
- const baseURL = oasInstance.api.servers?.at(serverIndex)?.url;
345
- return baseURL;
343
+ return oasInstance.api.servers?.at(serverIndex)?.url;
346
344
  },
347
345
  contentType
348
346
  };
349
347
  },
348
+ resolvePath(baseName, pathMode, options2) {
349
+ const root = path__default.default.resolve(this.config.root, this.config.output.path);
350
+ const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
351
+ if (mode === "single") {
352
+ return path__default.default.resolve(root, output.path);
353
+ }
354
+ return path__default.default.resolve(root, output.path, baseName);
355
+ },
350
356
  async buildStart() {
351
357
  if (!output) {
352
358
  return;
@@ -360,100 +366,63 @@ var pluginOas = core.createPlugin((options) => {
360
366
  }
361
367
  });
362
368
  await oas.dereference();
363
- const root = path__default.default.resolve(this.config.root, this.config.output.path);
364
- const schemas = chunkJRZ3YURA_cjs.getSchemas({ oas, contentType });
365
- const mapSchema = async ([name, schema]) => {
366
- const baseName = `${transformers.camelCase(name)}.json`;
367
- const resolvedPath = path__default.default.resolve(root, output.path, baseName);
368
- await this.addFile({
369
- path: resolvedPath,
370
- baseName,
371
- meta: {
372
- pluginKey: this.plugin.key
373
- },
374
- sources: [
375
- {
376
- name: transformers.camelCase(name),
377
- isExportable: false,
378
- isIndexable: false,
379
- value: JSON.stringify(schema)
380
- }
381
- ]
382
- });
383
- };
384
- const promises = Object.entries(schemas).map(mapSchema);
385
- await Promise.all(promises);
386
- }
387
- };
388
- });
389
-
390
- // src/generator.tsx
391
- chunkJRZ3YURA_cjs.init_cjs_shims();
392
- var import_jsx_runtime = chunkJRZ3YURA_cjs.__toESM(chunkFFFMYESV_cjs.require_jsx_runtime(), 1);
393
- function createGenerator(parseOptions) {
394
- return parseOptions;
395
- }
396
- function createReactGenerator(parseOptions) {
397
- return {
398
- ...parseOptions,
399
- async operations({ instance, options, operations, operationsByMethod }) {
400
- if (!parseOptions.Operations) {
401
- return [];
402
- }
403
- const { pluginManager, oas, plugin, mode } = instance.context;
404
- const root = react.createRoot({
405
- logger: pluginManager.logger
406
- });
407
- root.render(
408
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkFFFMYESV_cjs.Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operations, { operations, instance, operationsByMethod, options }) }) })
369
+ const schemaGenerator = new chunkAAIEMW6V_cjs.SchemaGenerator(
370
+ {
371
+ unknownType: "unknown",
372
+ dateType: "date",
373
+ transformers: {},
374
+ ...this.plugin.options
375
+ },
376
+ {
377
+ oas,
378
+ pluginManager: this.pluginManager,
379
+ plugin: this.plugin,
380
+ contentType,
381
+ include: void 0,
382
+ override: void 0,
383
+ mode: "split",
384
+ output: output.path
385
+ }
409
386
  );
410
- return root.files;
411
- },
412
- async operation({ instance, operation, options }) {
413
- if (!parseOptions.Operation) {
414
- return [];
415
- }
416
- const { pluginManager, oas, plugin, mode } = instance.context;
417
- const root = react.createRoot({
418
- logger: pluginManager.logger
387
+ const schemaFiles = await schemaGenerator.build(...generators);
388
+ await this.addFile(...schemaFiles);
389
+ const operationGenerator = new OperationGenerator(this.plugin.options, {
390
+ oas,
391
+ pluginManager: this.pluginManager,
392
+ plugin: this.plugin,
393
+ contentType,
394
+ exclude: void 0,
395
+ include: void 0,
396
+ override: void 0,
397
+ mode: "split"
419
398
  });
420
- root.render(
421
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkFFFMYESV_cjs.Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkFFFMYESV_cjs.Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operation, { operation, options, instance }) }) }) })
422
- );
423
- return root.files;
424
- },
425
- async schema({ instance, schema, name, options }) {
426
- if (!parseOptions.Schema) {
427
- return [];
428
- }
429
- const { pluginManager, oas, plugin, mode } = instance.context;
430
- const root = react.createRoot({
431
- logger: pluginManager.logger
432
- });
433
- const tree = instance.parse({ schema, name });
434
- root.render(
435
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkFFFMYESV_cjs.Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkFFFMYESV_cjs.Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Schema, { schema, options, instance, name }) }) }) })
436
- );
437
- return root.files;
399
+ const operationFiles = await operationGenerator.build(...generators);
400
+ await this.addFile(...operationFiles);
438
401
  }
439
402
  };
440
- }
403
+ });
441
404
 
405
+ Object.defineProperty(exports, "createGenerator", {
406
+ enumerable: true,
407
+ get: function () { return chunkI3ZL3GUQ_cjs.createGenerator; }
408
+ });
409
+ Object.defineProperty(exports, "createReactGenerator", {
410
+ enumerable: true,
411
+ get: function () { return chunkI3ZL3GUQ_cjs.createReactGenerator; }
412
+ });
442
413
  Object.defineProperty(exports, "SchemaGenerator", {
443
414
  enumerable: true,
444
- get: function () { return chunkFFFMYESV_cjs.SchemaGenerator; }
415
+ get: function () { return chunkAAIEMW6V_cjs.SchemaGenerator; }
445
416
  });
446
417
  Object.defineProperty(exports, "isKeyword", {
447
418
  enumerable: true,
448
- get: function () { return chunkFFFMYESV_cjs.isKeyword; }
419
+ get: function () { return chunkAAIEMW6V_cjs.isKeyword; }
449
420
  });
450
421
  Object.defineProperty(exports, "schemaKeywords", {
451
422
  enumerable: true,
452
- get: function () { return chunkFFFMYESV_cjs.schemaKeywords; }
423
+ get: function () { return chunkAAIEMW6V_cjs.schemaKeywords; }
453
424
  });
454
425
  exports.OperationGenerator = OperationGenerator;
455
- exports.createGenerator = createGenerator;
456
- exports.createReactGenerator = createReactGenerator;
457
426
  exports.pluginOas = pluginOas;
458
427
  exports.pluginOasName = pluginOasName;
459
428
  //# sourceMappingURL=index.cjs.map