@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.
- package/dist/{OperationGenerator-BqfyX5-8.d.cts → OperationGenerator-B5CoXmjA.d.cts} +22 -20
- package/dist/{OperationGenerator-BqfyX5-8.d.ts → OperationGenerator-B5CoXmjA.d.ts} +22 -20
- package/dist/{Schema-BgpIlA79.d.cts → Schema-BsgDay0E.d.cts} +1 -12
- package/dist/{Schema-ExMIJOhD.d.ts → Schema-Dvt6i_X3.d.ts} +1 -12
- package/dist/chunk-2QECZEUD.js +76 -0
- package/dist/chunk-2QECZEUD.js.map +1 -0
- package/dist/chunk-4OQEPWOG.js +38 -0
- package/dist/chunk-4OQEPWOG.js.map +1 -0
- package/dist/chunk-7Q5B67MW.cjs +1110 -0
- package/dist/chunk-7Q5B67MW.cjs.map +1 -0
- package/dist/chunk-7XBQZ7AX.js +1098 -0
- package/dist/chunk-7XBQZ7AX.js.map +1 -0
- package/dist/{chunk-AAIEMW6V.cjs → chunk-CQDZGAA6.cjs} +28 -798
- package/dist/chunk-CQDZGAA6.cjs.map +1 -0
- package/dist/{chunk-M3V3WMCW.js → chunk-CYF724QJ.js} +11 -773
- package/dist/chunk-CYF724QJ.js.map +1 -0
- package/dist/{chunk-PZTS5YZV.js → chunk-D2N6LDLT.js} +15 -13
- package/dist/chunk-D2N6LDLT.js.map +1 -0
- package/dist/{chunk-I3ZL3GUQ.cjs → chunk-LCPCIS3S.cjs} +19 -17
- package/dist/chunk-LCPCIS3S.cjs.map +1 -0
- package/dist/chunk-PUFCST25.cjs +84 -0
- package/dist/chunk-PUFCST25.cjs.map +1 -0
- package/dist/chunk-TYQZ2BD7.cjs +42 -0
- package/dist/chunk-TYQZ2BD7.cjs.map +1 -0
- package/dist/components.cjs +5 -6
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/components.js +2 -3
- package/dist/generators.cjs +4 -5
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +3 -4
- package/dist/hooks.cjs +102 -31
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +39 -6
- package/dist/hooks.d.ts +39 -6
- package/dist/hooks.js +92 -20
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +25 -410
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -400
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +12 -12
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +2 -3
- package/dist/utils.js.map +1 -1
- package/package.json +10 -10
- package/src/OperationGenerator.ts +11 -15
- package/src/SchemaGenerator.ts +14 -5
- package/src/components/Schema.tsx +1 -98
- package/src/generator.tsx +22 -14
- package/src/generators/jsonGenerator.ts +4 -4
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useOperationManager.ts +76 -29
- package/src/hooks/useSchemaManager.ts +76 -0
- package/src/utils/getParams.ts +1 -1
- package/dist/chunk-2PMRS7PB.cjs +0 -8
- package/dist/chunk-2PMRS7PB.cjs.map +0 -1
- package/dist/chunk-2V64GHQ4.js +0 -32
- package/dist/chunk-2V64GHQ4.js.map +0 -1
- package/dist/chunk-4JIFKRM5.js +0 -6
- package/dist/chunk-4JIFKRM5.js.map +0 -1
- package/dist/chunk-5ULY3TQB.cjs +0 -90
- package/dist/chunk-5ULY3TQB.cjs.map +0 -1
- package/dist/chunk-AAIEMW6V.cjs.map +0 -1
- package/dist/chunk-CFU6KMOB.cjs +0 -38
- package/dist/chunk-CFU6KMOB.cjs.map +0 -1
- package/dist/chunk-GAPWY2CE.js +0 -84
- package/dist/chunk-GAPWY2CE.js.map +0 -1
- package/dist/chunk-I3ZL3GUQ.cjs.map +0 -1
- package/dist/chunk-M3V3WMCW.js.map +0 -1
- package/dist/chunk-PZTS5YZV.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { require_jsx_runtime, Oas } from './chunk-
|
|
2
|
-
import { init_esm_shims, __toESM } from './chunk-
|
|
1
|
+
import { require_jsx_runtime, Oas } from './chunk-CYF724QJ.js';
|
|
2
|
+
import { init_esm_shims, __toESM } from './chunk-4OQEPWOG.js';
|
|
3
3
|
import { camelCase } from '@kubb/core/transformers';
|
|
4
4
|
import { createRoot, App } from '@kubb/react';
|
|
5
5
|
|
|
@@ -26,8 +26,9 @@ function createReactGenerator(parseOptions) {
|
|
|
26
26
|
const root = createRoot({
|
|
27
27
|
logger: pluginManager.logger
|
|
28
28
|
});
|
|
29
|
+
const Component = parseOptions.Operations.bind(this);
|
|
29
30
|
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)(
|
|
31
|
+
/* @__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)(Component, { operations, instance, operationsByMethod, options }) }) })
|
|
31
32
|
);
|
|
32
33
|
return root.files;
|
|
33
34
|
},
|
|
@@ -39,12 +40,13 @@ function createReactGenerator(parseOptions) {
|
|
|
39
40
|
const root = createRoot({
|
|
40
41
|
logger: pluginManager.logger
|
|
41
42
|
});
|
|
43
|
+
const Component = parseOptions.Operation.bind(this);
|
|
42
44
|
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)(
|
|
45
|
+
/* @__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)(Component, { operation, options, instance }) }) }) })
|
|
44
46
|
);
|
|
45
47
|
return root.files;
|
|
46
48
|
},
|
|
47
|
-
async schema({ instance, schema,
|
|
49
|
+
async schema({ instance, schema, options }) {
|
|
48
50
|
if (!parseOptions.Schema) {
|
|
49
51
|
return [];
|
|
50
52
|
}
|
|
@@ -52,9 +54,9 @@ function createReactGenerator(parseOptions) {
|
|
|
52
54
|
const root = createRoot({
|
|
53
55
|
logger: pluginManager.logger
|
|
54
56
|
});
|
|
55
|
-
const
|
|
57
|
+
const Component = parseOptions.Schema.bind(this);
|
|
56
58
|
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)(
|
|
59
|
+
/* @__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: schema.name, value: schema.value, tree: schema.tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { schema, options, instance }) }) }) })
|
|
58
60
|
);
|
|
59
61
|
return root.files;
|
|
60
62
|
}
|
|
@@ -64,10 +66,10 @@ function createReactGenerator(parseOptions) {
|
|
|
64
66
|
// src/generators/jsonGenerator.ts
|
|
65
67
|
var jsonGenerator = createGenerator({
|
|
66
68
|
name: "plugin-oas",
|
|
67
|
-
async schema({ schema,
|
|
69
|
+
async schema({ schema, instance }) {
|
|
68
70
|
const { pluginManager, plugin } = instance.context;
|
|
69
71
|
const file = pluginManager.getFile({
|
|
70
|
-
name: camelCase(name),
|
|
72
|
+
name: camelCase(schema.name),
|
|
71
73
|
extName: ".json",
|
|
72
74
|
mode: "split",
|
|
73
75
|
pluginKey: plugin.key
|
|
@@ -77,10 +79,10 @@ var jsonGenerator = createGenerator({
|
|
|
77
79
|
...file,
|
|
78
80
|
sources: [
|
|
79
81
|
{
|
|
80
|
-
name: camelCase(name),
|
|
82
|
+
name: camelCase(schema.name),
|
|
81
83
|
isExportable: false,
|
|
82
84
|
isIndexable: false,
|
|
83
|
-
value: JSON.stringify(schema)
|
|
85
|
+
value: JSON.stringify(schema.value)
|
|
84
86
|
}
|
|
85
87
|
]
|
|
86
88
|
}
|
|
@@ -89,5 +91,5 @@ var jsonGenerator = createGenerator({
|
|
|
89
91
|
});
|
|
90
92
|
|
|
91
93
|
export { createGenerator, createReactGenerator, jsonGenerator };
|
|
92
|
-
//# sourceMappingURL=chunk-
|
|
93
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-D2N6LDLT.js.map
|
|
95
|
+
//# sourceMappingURL=chunk-D2N6LDLT.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;AA4EY,IAAA,kBAAA,GAAA,OAAA,CAAA,mBAAA,EAAA,EAAA,CAAA,CAAA,CAAA;AAjCL,SAAS,gBAAuD,YAA+D,EAAA;AACpI,EAAO,OAAA,YAAA,CAAA;AACT,CA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AA,KACF,CAAA;AAAA,GACF;AACF,CAAC","file":"chunk-D2N6LDLT.js","sourcesContent":["export { jsonGenerator } from './jsonGenerator.ts'\n","import { camelCase } 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, instance }) {\n const { pluginManager, plugin } = instance.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extName: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\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 { Schema } from './SchemaMapper.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 schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n options: TOptions['resolvedOptions']\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, 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?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, 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 const Component = parseOptions.Operations.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Component 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 const Component = parseOptions.Operation.bind(this)\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 <Component 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, 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 Component = parseOptions.Schema.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} value={schema.value} tree={schema.tree}>\n <Component schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n }\n}\n"]}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkCQDZGAA6_cjs = require('./chunk-CQDZGAA6.cjs');
|
|
4
|
+
var chunkTYQZ2BD7_cjs = require('./chunk-TYQZ2BD7.cjs');
|
|
5
5
|
var transformers = require('@kubb/core/transformers');
|
|
6
6
|
var react = require('@kubb/react');
|
|
7
7
|
|
|
8
8
|
// src/generators/index.ts
|
|
9
|
-
|
|
9
|
+
chunkTYQZ2BD7_cjs.init_cjs_shims();
|
|
10
10
|
|
|
11
11
|
// src/generators/jsonGenerator.ts
|
|
12
|
-
|
|
12
|
+
chunkTYQZ2BD7_cjs.init_cjs_shims();
|
|
13
13
|
|
|
14
14
|
// src/generator.tsx
|
|
15
|
-
|
|
16
|
-
var import_jsx_runtime =
|
|
15
|
+
chunkTYQZ2BD7_cjs.init_cjs_shims();
|
|
16
|
+
var import_jsx_runtime = chunkTYQZ2BD7_cjs.__toESM(chunkCQDZGAA6_cjs.require_jsx_runtime(), 1);
|
|
17
17
|
function createGenerator(parseOptions) {
|
|
18
18
|
return parseOptions;
|
|
19
19
|
}
|
|
@@ -28,8 +28,9 @@ function createReactGenerator(parseOptions) {
|
|
|
28
28
|
const root = react.createRoot({
|
|
29
29
|
logger: pluginManager.logger
|
|
30
30
|
});
|
|
31
|
+
const Component = parseOptions.Operations.bind(this);
|
|
31
32
|
root.render(
|
|
32
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
33
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkCQDZGAA6_cjs.Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { operations, instance, operationsByMethod, options }) }) })
|
|
33
34
|
);
|
|
34
35
|
return root.files;
|
|
35
36
|
},
|
|
@@ -41,12 +42,13 @@ function createReactGenerator(parseOptions) {
|
|
|
41
42
|
const root = react.createRoot({
|
|
42
43
|
logger: pluginManager.logger
|
|
43
44
|
});
|
|
45
|
+
const Component = parseOptions.Operation.bind(this);
|
|
44
46
|
root.render(
|
|
45
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
47
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkCQDZGAA6_cjs.Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkCQDZGAA6_cjs.Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { operation, options, instance }) }) }) })
|
|
46
48
|
);
|
|
47
49
|
return root.files;
|
|
48
50
|
},
|
|
49
|
-
async schema({ instance, schema,
|
|
51
|
+
async schema({ instance, schema, options }) {
|
|
50
52
|
if (!parseOptions.Schema) {
|
|
51
53
|
return [];
|
|
52
54
|
}
|
|
@@ -54,9 +56,9 @@ function createReactGenerator(parseOptions) {
|
|
|
54
56
|
const root = react.createRoot({
|
|
55
57
|
logger: pluginManager.logger
|
|
56
58
|
});
|
|
57
|
-
const
|
|
59
|
+
const Component = parseOptions.Schema.bind(this);
|
|
58
60
|
root.render(
|
|
59
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
61
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkCQDZGAA6_cjs.Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkCQDZGAA6_cjs.Oas.Schema, { name: schema.name, value: schema.value, tree: schema.tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { schema, options, instance }) }) }) })
|
|
60
62
|
);
|
|
61
63
|
return root.files;
|
|
62
64
|
}
|
|
@@ -66,10 +68,10 @@ function createReactGenerator(parseOptions) {
|
|
|
66
68
|
// src/generators/jsonGenerator.ts
|
|
67
69
|
var jsonGenerator = createGenerator({
|
|
68
70
|
name: "plugin-oas",
|
|
69
|
-
async schema({ schema,
|
|
71
|
+
async schema({ schema, instance }) {
|
|
70
72
|
const { pluginManager, plugin } = instance.context;
|
|
71
73
|
const file = pluginManager.getFile({
|
|
72
|
-
name: transformers.camelCase(name),
|
|
74
|
+
name: transformers.camelCase(schema.name),
|
|
73
75
|
extName: ".json",
|
|
74
76
|
mode: "split",
|
|
75
77
|
pluginKey: plugin.key
|
|
@@ -79,10 +81,10 @@ var jsonGenerator = createGenerator({
|
|
|
79
81
|
...file,
|
|
80
82
|
sources: [
|
|
81
83
|
{
|
|
82
|
-
name: transformers.camelCase(name),
|
|
84
|
+
name: transformers.camelCase(schema.name),
|
|
83
85
|
isExportable: false,
|
|
84
86
|
isIndexable: false,
|
|
85
|
-
value: JSON.stringify(schema)
|
|
87
|
+
value: JSON.stringify(schema.value)
|
|
86
88
|
}
|
|
87
89
|
]
|
|
88
90
|
}
|
|
@@ -93,5 +95,5 @@ var jsonGenerator = createGenerator({
|
|
|
93
95
|
exports.createGenerator = createGenerator;
|
|
94
96
|
exports.createReactGenerator = createReactGenerator;
|
|
95
97
|
exports.jsonGenerator = jsonGenerator;
|
|
96
|
-
//# sourceMappingURL=chunk-
|
|
97
|
-
//# sourceMappingURL=chunk-
|
|
98
|
+
//# sourceMappingURL=chunk-LCPCIS3S.cjs.map
|
|
99
|
+
//# sourceMappingURL=chunk-LCPCIS3S.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generators/index.ts","../src/generators/jsonGenerator.ts","../src/generator.tsx"],"names":["init_cjs_shims","__toESM","require_jsx_runtime","createRoot","App","Oas","camelCase"],"mappings":";;;;;;;;AAAAA,gCAAA,EAAA,CAAA;;;ACAAA,gCAAA,EAAA,CAAA;;;ACAAA,gCAAA,EAAA,CAAA;AA4EY,IAAA,kBAAA,GAAAC,yBAAA,CAAAC,qCAAA,EAAA,EAAA,CAAA,CAAA,CAAA;AAjCL,SAAS,gBAAuD,YAA+D,EAAA;AACpI,EAAO,OAAA,YAAA,CAAA;AACT,CAAA;AAaO,SAAS,qBAA4D,YAAoE,EAAA;AAC9I,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,MAAM,UAAW,CAAA,EAAE,UAAU,OAAS,EAAA,UAAA,EAAY,oBAAsB,EAAA;AACtE,MAAI,IAAA,CAAC,aAAa,UAAY,EAAA;AAC5B,QAAA,OAAO,EAAC,CAAA;AAAA,OACV;AAEA,MAAA,MAAM,EAAE,aAAe,EAAA,GAAA,EAAK,MAAQ,EAAA,IAAA,KAAS,QAAS,CAAA,OAAA,CAAA;AACtD,MAAA,MAAM,OAAOC,gBAAW,CAAA;AAAA,QACtB,QAAQ,aAAc,CAAA,MAAA;AAAA,OACvB,CAAA,CAAA;AAED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AAK,CAAA,KAAA,CAAA;AAAA,KACd;AAAA,GACF,CAAA;AACF,CAAA;;;ADhIO,IAAM,gBAAgB,eAA2B,CAAA;AAAA,EACtD,IAAM,EAAA,YAAA;AAAA,EACN,MAAM,MAAA,CAAO,EAAE,MAAA,EAAQ,UAAY,EAAA;AACjC,IAAA,MAAM,EAAE,aAAA,EAAe,MAAO,EAAA,GAAI,QAAS,CAAA,OAAA,CAAA;AAC3C,IAAM,MAAA,IAAA,GAAO,cAAc,OAAQ,CAAA;AAAA,MACjC,IAAA,EAAMC,sBAAU,CAAA,MAAA,CAAO,IAAI,CAAA;AAAA,MAC3B,OAAS,EAAA,OAAA;AAAA,MACT,IAAM,EAAA,OAAA;AAAA,MACN,WAAW,MAAO,CAAA,GAAA;AAAA,KACnB,CAAA,CAAA;AAED,IAAO,OAAA;AAAA,MACL;AAAA,QACE,GAAG,IAAA;AAAA,QACH,OAAS,EAAA;AAAA,UACP;AAAA,YACE,IAAA,EAAMA,sBAAU,CAAA,MAAA,CAAO,IAAI,CAAA;AAAA,YAC3B,YAAc,EAAA,KAAA;AAAA,YACd,WAAa,EAAA,KAAA;AAAA,YACb,KAAO,EAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,KAAK,CAAA;AAAA,WACpC;AAAA,SACF;AAAA,OACF;AAAA,KACF,CAAA;AAAA,GACF;AACF,CAAC","file":"chunk-LCPCIS3S.cjs","sourcesContent":["export { jsonGenerator } from './jsonGenerator.ts'\n","import { camelCase } 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, instance }) {\n const { pluginManager, plugin } = instance.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extName: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\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 { Schema } from './SchemaMapper.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 schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n options: TOptions['resolvedOptions']\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, 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?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, 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 const Component = parseOptions.Operations.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Component 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 const Component = parseOptions.Operation.bind(this)\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 <Component 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, 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 Component = parseOptions.Schema.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} value={schema.value} tree={schema.tree}>\n <Component schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n }\n}\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkTYQZ2BD7_cjs = require('./chunk-TYQZ2BD7.cjs');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var utils = require('@kubb/core/utils');
|
|
6
|
+
var parser = require('@kubb/oas/parser');
|
|
7
|
+
var oas = require('@kubb/oas');
|
|
8
|
+
var yaml = require('@stoplight/yaml');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var yaml__default = /*#__PURE__*/_interopDefault(yaml);
|
|
13
|
+
|
|
14
|
+
// src/utils/getSchemas.ts
|
|
15
|
+
chunkTYQZ2BD7_cjs.init_cjs_shims();
|
|
16
|
+
function getSchemas({ oas, contentType, includes = ["schemas", "requestBodies", "responses"] }) {
|
|
17
|
+
const components = oas.getDefinition().components;
|
|
18
|
+
let schemas = {};
|
|
19
|
+
if (includes.includes("schemas")) {
|
|
20
|
+
schemas = {
|
|
21
|
+
...schemas,
|
|
22
|
+
...components?.schemas || {}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const requestBodies = components?.requestBodies || {};
|
|
26
|
+
if (includes.includes("responses")) {
|
|
27
|
+
const responses = components?.responses || {};
|
|
28
|
+
Object.entries(responses).forEach(([name, response]) => {
|
|
29
|
+
if (response.content && !schemas[name]) {
|
|
30
|
+
const firstContentType = Object.keys(response.content)[0] || "application/json";
|
|
31
|
+
schemas[name] = response.content?.[contentType || firstContentType]?.schema;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (includes.includes("requestBodies")) {
|
|
36
|
+
Object.entries(requestBodies).forEach(([name, request]) => {
|
|
37
|
+
if (request.content && !schemas[name]) {
|
|
38
|
+
const firstContentType = Object.keys(request.content)[0] || "application/json";
|
|
39
|
+
schemas[name] = request.content?.[contentType || firstContentType]?.schema;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return schemas;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/utils/parseFromConfig.ts
|
|
47
|
+
chunkTYQZ2BD7_cjs.init_cjs_shims();
|
|
48
|
+
function parseFromConfig(config, options = {}, oasClass = oas.Oas) {
|
|
49
|
+
if ("data" in config.input) {
|
|
50
|
+
if (typeof config.input.data === "object") {
|
|
51
|
+
const api2 = JSON.parse(JSON.stringify(config.input.data));
|
|
52
|
+
return parser.parse(api2, options, oasClass);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const api2 = yaml__default.default.parse(config.input.data);
|
|
56
|
+
return parser.parse(api2, options, oasClass);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
}
|
|
59
|
+
const api = JSON.parse(JSON.stringify(config.input.data));
|
|
60
|
+
return parser.parse(api, options, oasClass);
|
|
61
|
+
}
|
|
62
|
+
if (new utils.URLPath(config.input.path).isURL) {
|
|
63
|
+
return parser.parse(config.input.path, options, oasClass);
|
|
64
|
+
}
|
|
65
|
+
return parser.parse(path.resolve(config.root, config.input.path), options, oasClass);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/utils/getSchemaFactory.ts
|
|
69
|
+
chunkTYQZ2BD7_cjs.init_cjs_shims();
|
|
70
|
+
function getSchemaFactory(oas$1) {
|
|
71
|
+
return (schema) => {
|
|
72
|
+
const version = oas.isOpenApiV3_1Document(oas$1.api) ? "3.1" : "3.0";
|
|
73
|
+
return {
|
|
74
|
+
schema,
|
|
75
|
+
version
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
exports.getSchemaFactory = getSchemaFactory;
|
|
81
|
+
exports.getSchemas = getSchemas;
|
|
82
|
+
exports.parseFromConfig = parseFromConfig;
|
|
83
|
+
//# sourceMappingURL=chunk-PUFCST25.cjs.map
|
|
84
|
+
//# sourceMappingURL=chunk-PUFCST25.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/getSchemas.ts","../src/utils/parseFromConfig.ts","../src/utils/getSchemaFactory.ts"],"names":["init_cjs_shims","Oas","api","parse","yaml","URLPath","resolve","oas","isOpenApiV3_1Document"],"mappings":";;;;;;;;;;;;;;AAAAA,gCAAA,EAAA,CAAA;AAUO,SAAS,UAAA,CAAW,EAAE,GAAA,EAAK,WAAa,EAAA,QAAA,GAAW,CAAC,SAAW,EAAA,eAAA,EAAiB,WAAW,CAAA,EAA6D,EAAA;AAC7J,EAAM,MAAA,UAAA,GAAa,GAAI,CAAA,aAAA,EAAgB,CAAA,UAAA,CAAA;AAEvC,EAAA,IAAI,UAAiD,EAAC,CAAA;AAEtD,EAAI,IAAA,QAAA,CAAS,QAAS,CAAA,SAAS,CAAG,EAAA;AAChC,IAAU,OAAA,GAAA;AAAA,MACR,GAAG,OAAA;AAAA,MACH,GAAK,UAAY,EAAA,OAAA,IAAqD,EAAC;AAAA,KACzE,CAAA;AAAA,GACF;AAEA,EAAM,MAAA,aAAA,GAAgB,UAAY,EAAA,aAAA,IAAiB,EAAC,CAAA;AACpD,EAAI,IAAA,QAAA,CAAS,QAAS,CAAA,WAAW,CAAG,EAAA;AAClC,IAAM,MAAA,SAAA,GAAY,UAAY,EAAA,SAAA,IAAa,EAAC,CAAA;AAE5C,IAAO,MAAA,CAAA,OAAA,CAAQ,SAAS,CAAE,CAAA,OAAA,CAAQ,CAAC,CAAC,IAAA,EAAM,QAAQ,CAAyC,KAAA;AACzF,MAAA,IAAI,QAAS,CAAA,OAAA,IAAW,CAAC,OAAA,CAAQ,IAAI,CAAG,EAAA;AACtC,QAAA,MAAM,mBAAmB,MAAO,CAAA,IAAA,CAAK,SAAS,OAAO,CAAA,CAAE,CAAC,CAAK,IAAA,kBAAA,CAAA;AAC7D,QAAA,OAAA,CAAQ,IAAI,CAAI,GAAA,QAAA,CAAS,OAAU,GAAA,WAAA,IAAe,gBAAgB,CAAG,EAAA,MAAA,CAAA;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AA;AAAA,aAC5B,CAAG,EAAA;AAAA,KAEZ;AAEA,IAAM,MAAA,GAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA,CAAA;AAE9E,IAAO,OAAAC,YAAA,CAAM,GAAK,EAAA,OAAA,EAAS,QAAQ,CAAA,CAAA;AAAA,GACrC;AAEA,EAAA,IAAI,IAAIE,aAAQ,CAAA,MAAA,CAAO,KAAM,CAAA,IAAI,EAAE,KAAO,EAAA;AACxC,IAAA,OAAOF,YAAM,CAAA,MAAA,CAAO,KAAM,CAAA,IAAA,EAAM,SAAS,QAAQ,CAAA,CAAA;AAAA,GACnD;AAEA,EAAO,OAAAA,YAAA,CAAMG,aAAQ,MAAO,CAAA,IAAA,EAAM,OAAO,KAAM,CAAA,IAAI,CAAG,EAAA,OAAA,EAAS,QAAQ,CAAA,CAAA;AACzE,CAAA;;;ACnCAN,gCAAA,EAAA,CAAA;AAuBO,SAAS,iBAAmDO,KAA6D,EAAA;AAC9H,EAAA,OAAO,CAAC,MAA0B,KAAA;AAChC,IAAA,MAAM,OAAU,GAAAC,yBAAA,CAAsBD,KAAI,CAAA,GAAG,IAAI,KAAQ,GAAA,KAAA,CAAA;AAEzD,IAAO,OAAA;AAAA,MACL,MAAA;AAAA,MACA,OAAA;AAAA,KACF,CAAA;AAAA,GACF,CAAA;AACF","file":"chunk-PUFCST25.cjs","sourcesContent":["import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\nexport type GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n","import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { type FormatOptions, parse } from '@kubb/oas/parser'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, options, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, options, oasClass)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, options, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, options, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), options, oasClass)\n}\n","import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schema?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schema?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schema,\n version,\n } as SchemaResult<TWithRef>\n }\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __esm = (fn, res) => function __init() {
|
|
10
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
+
};
|
|
12
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
13
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
// ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.5__@swc+core@1.7.22_jiti@1.21.6__vgec2xea2cg5zleragji3g6qgq/node_modules/tsup/assets/cjs_shims.js
|
|
33
|
+
var init_cjs_shims = __esm({
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.5__@swc+core@1.7.22_jiti@1.21.6__vgec2xea2cg5zleragji3g6qgq/node_modules/tsup/assets/cjs_shims.js"() {
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
exports.__commonJS = __commonJS;
|
|
39
|
+
exports.__toESM = __toESM;
|
|
40
|
+
exports.init_cjs_shims = init_cjs_shims;
|
|
41
|
+
//# sourceMappingURL=chunk-TYQZ2BD7.cjs.map
|
|
42
|
+
//# sourceMappingURL=chunk-TYQZ2BD7.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.5__@swc+core@1.7.22_jiti@1.21.6__vgec2xea2cg5zleragji3g6qgq/node_modules/tsup/assets/cjs_shims.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,cAAA,GAAA,KAAA,CAAA;AAAA,EAAA,yLAAA,GAAA;AAAA,GAAA;AAAA,CAAA","file":"chunk-TYQZ2BD7.cjs","sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"]}
|
package/dist/components.cjs
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./chunk-
|
|
4
|
-
|
|
5
|
-
require('./chunk-5ULY3TQB.cjs');
|
|
3
|
+
var chunkCQDZGAA6_cjs = require('./chunk-CQDZGAA6.cjs');
|
|
4
|
+
require('./chunk-TYQZ2BD7.cjs');
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
Object.defineProperty(exports, "Oas", {
|
|
10
9
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkCQDZGAA6_cjs.Oas; }
|
|
12
11
|
});
|
|
13
12
|
Object.defineProperty(exports, "Operation", {
|
|
14
13
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkCQDZGAA6_cjs.Operation; }
|
|
16
15
|
});
|
|
17
16
|
Object.defineProperty(exports, "Schema", {
|
|
18
17
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkCQDZGAA6_cjs.Schema; }
|
|
20
19
|
});
|
|
21
20
|
//# sourceMappingURL=components.cjs.map
|
|
22
21
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as Schema } from './Schema-
|
|
1
|
+
import { S as Schema } from './Schema-BsgDay0E.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 { b as OperationGenerator } from './OperationGenerator-
|
|
5
|
+
import { b as OperationGenerator } from './OperationGenerator-B5CoXmjA.cjs';
|
|
6
6
|
import '@kubb/core';
|
|
7
7
|
import '@kubb/fs/types';
|
|
8
8
|
import '@kubb/oas/parser';
|
package/dist/components.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as Schema } from './Schema-
|
|
1
|
+
import { S as Schema } from './Schema-Dvt6i_X3.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 { b as OperationGenerator } from './OperationGenerator-
|
|
5
|
+
import { b as OperationGenerator } from './OperationGenerator-B5CoXmjA.js';
|
|
6
6
|
import '@kubb/core';
|
|
7
7
|
import '@kubb/fs/types';
|
|
8
8
|
import '@kubb/oas/parser';
|
package/dist/components.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import './chunk-GAPWY2CE.js';
|
|
1
|
+
export { Oas, Operation, Schema } from './chunk-CYF724QJ.js';
|
|
2
|
+
import './chunk-4OQEPWOG.js';
|
|
4
3
|
//# sourceMappingURL=components.js.map
|
|
5
4
|
//# sourceMappingURL=components.js.map
|
package/dist/generators.cjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-5ULY3TQB.cjs');
|
|
3
|
+
var chunkLCPCIS3S_cjs = require('./chunk-LCPCIS3S.cjs');
|
|
4
|
+
require('./chunk-CQDZGAA6.cjs');
|
|
5
|
+
require('./chunk-TYQZ2BD7.cjs');
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
Object.defineProperty(exports, "jsonGenerator", {
|
|
11
10
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkLCPCIS3S_cjs.jsonGenerator; }
|
|
13
12
|
});
|
|
14
13
|
//# sourceMappingURL=generators.cjs.map
|
|
15
14
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/generators.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { jsonGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-GAPWY2CE.js';
|
|
1
|
+
export { jsonGenerator } from './chunk-D2N6LDLT.js';
|
|
2
|
+
import './chunk-CYF724QJ.js';
|
|
3
|
+
import './chunk-4OQEPWOG.js';
|
|
5
4
|
//# sourceMappingURL=generators.js.map
|
|
6
5
|
//# sourceMappingURL=generators.js.map
|