@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.
- package/dist/OperationGenerator-BqfyX5-8.d.cts +554 -0
- package/dist/OperationGenerator-BqfyX5-8.d.ts +554 -0
- package/dist/{Schema-B1vcPGiK.d.ts → Schema-BgpIlA79.d.cts} +2 -2
- package/dist/{Schema-DoSFh7Qd.d.cts → Schema-ExMIJOhD.d.ts} +2 -2
- package/dist/chunk-2PMRS7PB.cjs +8 -0
- package/dist/{chunk-KW7GCBTZ.cjs.map → chunk-2PMRS7PB.cjs.map} +1 -1
- package/dist/{chunk-TEEWKGS3.js → chunk-2V64GHQ4.js} +3 -3
- package/dist/{chunk-TEEWKGS3.js.map → chunk-2V64GHQ4.js.map} +1 -1
- package/dist/chunk-4JIFKRM5.js +6 -0
- package/dist/{chunk-N3GACHZX.js.map → chunk-4JIFKRM5.js.map} +1 -1
- package/dist/{chunk-JRZ3YURA.cjs → chunk-5ULY3TQB.cjs} +4 -4
- package/dist/{chunk-JRZ3YURA.cjs.map → chunk-5ULY3TQB.cjs.map} +1 -1
- package/dist/{chunk-FFFMYESV.cjs → chunk-AAIEMW6V.cjs} +27 -27
- package/dist/chunk-AAIEMW6V.cjs.map +1 -0
- package/dist/{chunk-G35AGMCZ.cjs → chunk-CFU6KMOB.cjs} +4 -4
- package/dist/{chunk-G35AGMCZ.cjs.map → chunk-CFU6KMOB.cjs.map} +1 -1
- package/dist/{chunk-NW6726BC.js → chunk-GAPWY2CE.js} +4 -4
- package/dist/{chunk-NW6726BC.js.map → chunk-GAPWY2CE.js.map} +1 -1
- package/dist/chunk-I3ZL3GUQ.cjs +97 -0
- package/dist/chunk-I3ZL3GUQ.cjs.map +1 -0
- package/dist/{chunk-5QUCRUOD.js → chunk-M3V3WMCW.js} +4 -4
- package/dist/chunk-M3V3WMCW.js.map +1 -0
- package/dist/chunk-PZTS5YZV.js +93 -0
- package/dist/chunk-PZTS5YZV.js.map +1 -0
- package/dist/components.cjs +6 -6
- package/dist/components.d.cts +3 -5
- package/dist/components.d.ts +3 -5
- package/dist/components.js +3 -3
- package/dist/generators.cjs +15 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +10 -0
- package/dist/generators.d.ts +10 -0
- package/dist/generators.js +6 -0
- package/dist/generators.js.map +1 -0
- package/dist/hooks.cjs +12 -12
- package/dist/hooks.d.cts +3 -4
- package/dist/hooks.d.ts +3 -4
- package/dist/hooks.js +3 -3
- package/dist/index.cjs +69 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +57 -93
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +9 -9
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +3 -3
- package/package.json +18 -10
- package/src/components/Schema.tsx +1 -2
- package/src/generators/index.ts +1 -0
- package/src/generators/jsonGenerator.ts +30 -0
- package/src/plugin.ts +63 -43
- package/src/types.ts +23 -12
- package/dist/OperationGenerator-By5WOmWB.d.ts +0 -165
- package/dist/OperationGenerator-Gd1X7wUz.d.cts +0 -165
- package/dist/SchemaMapper-sGcY1xL5.d.cts +0 -247
- package/dist/SchemaMapper-sGcY1xL5.d.ts +0 -247
- package/dist/chunk-5QUCRUOD.js.map +0 -1
- package/dist/chunk-FFFMYESV.cjs.map +0 -1
- package/dist/chunk-KW7GCBTZ.cjs +0 -8
- package/dist/chunk-N3GACHZX.js +0 -6
- package/dist/types-CZTUCaE5.d.cts +0 -145
- package/dist/types-CZTUCaE5.d.ts +0 -145
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk5ULY3TQB_cjs = require('./chunk-5ULY3TQB.cjs');
|
|
4
4
|
var path = require('path');
|
|
5
5
|
var utils = require('@kubb/core/utils');
|
|
6
6
|
var parser = require('@kubb/oas/parser');
|
|
@@ -12,7 +12,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
12
12
|
var yaml__default = /*#__PURE__*/_interopDefault(yaml);
|
|
13
13
|
|
|
14
14
|
// src/utils/parseFromConfig.ts
|
|
15
|
-
|
|
15
|
+
chunk5ULY3TQB_cjs.init_cjs_shims();
|
|
16
16
|
function parseFromConfig(config, options = {}, oasClass = oas.Oas) {
|
|
17
17
|
if ("data" in config.input) {
|
|
18
18
|
if (typeof config.input.data === "object") {
|
|
@@ -34,5 +34,5 @@ function parseFromConfig(config, options = {}, oasClass = oas.Oas) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
exports.parseFromConfig = parseFromConfig;
|
|
37
|
-
//# sourceMappingURL=chunk-
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
37
|
+
//# sourceMappingURL=chunk-CFU6KMOB.cjs.map
|
|
38
|
+
//# sourceMappingURL=chunk-CFU6KMOB.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/parseFromConfig.ts"],"names":["init_cjs_shims","Oas","api","parse","yaml","URLPath","resolve"],"mappings":";;;;;;;;;;;;;;AAAAA,gCAAA,EAAA,CAAA;AAUO,SAAS,gBAAgB,MAAgB,EAAA,OAAA,GAAyB,EAAC,EAAG,WAAuBC,OAAmB,EAAA;AACrH,EAAI,IAAA,MAAA,IAAU,OAAO,KAAO,EAAA;AAC1B,IAAA,IAAI,OAAO,MAAA,CAAO,KAAM,CAAA,IAAA,KAAS,QAAU,EAAA;AACzC,MAAMC,MAAAA,IAAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA,CAAA;AAC9E,MAAO,OAAAC,YAAA,CAAMD,IAAK,EAAA,OAAA,EAAS,QAAQ,CAAA,CAAA;AAAA,KACrC;AAEA,IAAI,IAAA;AACF,MAAA,MAA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AK,EAAA,OAAA,EAAS,QAAQ,CAAA,CAAA;AAAA,KACrC;AAEA,IAAI,IAAA;AACF,MAAA,MAAMA,IAAc,GAAAE,qBAAA,CAAK,KAAM,CAAA,MAAA,CAAO,MAAM,IAAc,CAAA,CAAA;AAE1D,MAAO,OAAAD,YAAA,CAAMD,IAAK,EAAA,OAAA,EAAS,QAAQ,CAAA,CAAA;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","file":"chunk-CFU6KMOB.cjs","sourcesContent":["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"]}
|
|
@@ -29,9 +29,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
mod
|
|
30
30
|
));
|
|
31
31
|
|
|
32
|
-
// ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.
|
|
32
|
+
// ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.4__@swc+core@1.7.22_jiti@1.21.6__fpzbqwwca26qndurg5tnw6xyfi/node_modules/tsup/assets/esm_shims.js
|
|
33
33
|
var init_esm_shims = __esm({
|
|
34
|
-
"../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.4__@swc+core@1.7.22_jiti@1.21.6__fpzbqwwca26qndurg5tnw6xyfi/node_modules/tsup/assets/esm_shims.js"() {
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
|
|
@@ -80,5 +80,5 @@ function getSchemaFactory(oas) {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
export { __commonJS, __toESM, getSchemaFactory, getSchemas, init_esm_shims };
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
84
|
-
//# sourceMappingURL=chunk-
|
|
83
|
+
//# sourceMappingURL=chunk-GAPWY2CE.js.map
|
|
84
|
+
//# sourceMappingURL=chunk-GAPWY2CE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.4__@swc+core@1.7.22_jiti@1.21.6__fpzbqwwca26qndurg5tnw6xyfi/node_modules/tsup/assets/esm_shims.js","../src/utils/getSchemas.ts","../src/utils/getSchemaFactory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,cAAA,GAAA,KAAA,CAAA;AAAA,EAAA,yLAAA,GAAA;AAAA,GAAA;AAAA,CAAA,EAAA;;;ACAA,cAAA,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;AAAA,OACvE;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AAEA,EAAI,IAAA,QAAA,CAAS,QAAS,CAAA,eAAe,CAAG,EAAA;AACtC,IAAO,MAAA,CAAA,OAAA,CAAQ,aAAa,CAAE,CAAA,OAAA,CAAQ,CAAC,CAAC,IAAA,EAAM,OAAO,CAA4C,KAAA;AAC/F,MAAA,IAAI,OAAQ,CAAA,OAAA,IAAW,CAAC,OAAA,CAAQ,IAAI,CAAG,EAAA;AACrC,QAAA,MAAM,mBAAmB,MAAO,CAAA,IAAA,CAAK,QAAQ,OAAO,CAAA,CAAE,CAAC,CAAK,IAAA,kBAAA,CAAA;AAC5D,QAAA,OAAA,CAAQ,IAAI,CAAI,GAAA,OAAA,CAAQ,OAAU,GAAA,WAAA,IAAe,gBAAgB,CAAG,EAAA,MAAA,CAAA;AAAA,OACtE;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AAEA,EAAO,OAAA,OAAA,CAAA;AACT,CAAA;;;AC5CA,cAAA,EAAA,CAAA;AAuBO,SAAS,iBAAmD,GAA6D,EAAA;AAC9H,EAAA,OAAO,CAAC,MAA0B,KAAA;AAChC,IAAA,MAAM,OAAU,GAAA,qBAAA,CAAsB,GAAI,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-GAPWY2CE.js","sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\nexport type GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n","import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schema?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schema?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schema,\n version,\n } as SchemaResult<TWithRef>\n }\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkAAIEMW6V_cjs = require('./chunk-AAIEMW6V.cjs');
|
|
4
|
+
var chunk5ULY3TQB_cjs = require('./chunk-5ULY3TQB.cjs');
|
|
5
|
+
var transformers = require('@kubb/core/transformers');
|
|
6
|
+
var react = require('@kubb/react');
|
|
7
|
+
|
|
8
|
+
// src/generators/index.ts
|
|
9
|
+
chunk5ULY3TQB_cjs.init_cjs_shims();
|
|
10
|
+
|
|
11
|
+
// src/generators/jsonGenerator.ts
|
|
12
|
+
chunk5ULY3TQB_cjs.init_cjs_shims();
|
|
13
|
+
|
|
14
|
+
// src/generator.tsx
|
|
15
|
+
chunk5ULY3TQB_cjs.init_cjs_shims();
|
|
16
|
+
var import_jsx_runtime = chunk5ULY3TQB_cjs.__toESM(chunkAAIEMW6V_cjs.require_jsx_runtime(), 1);
|
|
17
|
+
function createGenerator(parseOptions) {
|
|
18
|
+
return parseOptions;
|
|
19
|
+
}
|
|
20
|
+
function createReactGenerator(parseOptions) {
|
|
21
|
+
return {
|
|
22
|
+
...parseOptions,
|
|
23
|
+
async operations({ instance, options, operations, operationsByMethod }) {
|
|
24
|
+
if (!parseOptions.Operations) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
28
|
+
const root = react.createRoot({
|
|
29
|
+
logger: pluginManager.logger
|
|
30
|
+
});
|
|
31
|
+
root.render(
|
|
32
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkAAIEMW6V_cjs.Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operations, { operations, instance, operationsByMethod, options }) }) })
|
|
33
|
+
);
|
|
34
|
+
return root.files;
|
|
35
|
+
},
|
|
36
|
+
async operation({ instance, operation, options }) {
|
|
37
|
+
if (!parseOptions.Operation) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
41
|
+
const root = react.createRoot({
|
|
42
|
+
logger: pluginManager.logger
|
|
43
|
+
});
|
|
44
|
+
root.render(
|
|
45
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkAAIEMW6V_cjs.Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkAAIEMW6V_cjs.Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operation, { operation, options, instance }) }) }) })
|
|
46
|
+
);
|
|
47
|
+
return root.files;
|
|
48
|
+
},
|
|
49
|
+
async schema({ instance, schema, name, options }) {
|
|
50
|
+
if (!parseOptions.Schema) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
54
|
+
const root = react.createRoot({
|
|
55
|
+
logger: pluginManager.logger
|
|
56
|
+
});
|
|
57
|
+
const tree = instance.parse({ schema, name });
|
|
58
|
+
root.render(
|
|
59
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkAAIEMW6V_cjs.Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(chunkAAIEMW6V_cjs.Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Schema, { schema, options, instance, name }) }) }) })
|
|
60
|
+
);
|
|
61
|
+
return root.files;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/generators/jsonGenerator.ts
|
|
67
|
+
var jsonGenerator = createGenerator({
|
|
68
|
+
name: "plugin-oas",
|
|
69
|
+
async schema({ schema, name, instance }) {
|
|
70
|
+
const { pluginManager, plugin } = instance.context;
|
|
71
|
+
const file = pluginManager.getFile({
|
|
72
|
+
name: transformers.camelCase(name),
|
|
73
|
+
extName: ".json",
|
|
74
|
+
mode: "split",
|
|
75
|
+
pluginKey: plugin.key
|
|
76
|
+
});
|
|
77
|
+
return [
|
|
78
|
+
{
|
|
79
|
+
...file,
|
|
80
|
+
sources: [
|
|
81
|
+
{
|
|
82
|
+
name: transformers.camelCase(name),
|
|
83
|
+
isExportable: false,
|
|
84
|
+
isIndexable: false,
|
|
85
|
+
value: JSON.stringify(schema)
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
exports.createGenerator = createGenerator;
|
|
94
|
+
exports.createReactGenerator = createReactGenerator;
|
|
95
|
+
exports.jsonGenerator = jsonGenerator;
|
|
96
|
+
//# sourceMappingURL=chunk-I3ZL3GUQ.cjs.map
|
|
97
|
+
//# sourceMappingURL=chunk-I3ZL3GUQ.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,CAA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AAA,SAAA,CAAU,MAAM,CAAA;AAAA,WAC9B;AAAA,SACF;AAAA,OACF;AAAA,KACF,CAAA;AAAA,GACF;AACF,CAAC","file":"chunk-I3ZL3GUQ.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, 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,4 +1,4 @@
|
|
|
1
|
-
import { __commonJS, init_esm_shims, __toESM, getSchemaFactory, getSchemas } from './chunk-
|
|
1
|
+
import { __commonJS, init_esm_shims, __toESM, getSchemaFactory, getSchemas } from './chunk-GAPWY2CE.js';
|
|
2
2
|
import { BaseGenerator } from '@kubb/core';
|
|
3
3
|
import transformers, { pascalCase } from '@kubb/core/transformers';
|
|
4
4
|
import { getUniqueName } from '@kubb/core/utils';
|
|
@@ -3797,7 +3797,7 @@ var SchemaContext = createContext({
|
|
|
3797
3797
|
function Schema({ name, value, tree = [], children }) {
|
|
3798
3798
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SchemaContext.Provider, { value: { name, schema: value, tree }, children });
|
|
3799
3799
|
}
|
|
3800
|
-
Schema.File = function({
|
|
3800
|
+
Schema.File = function({ isTypeOnly, children }) {
|
|
3801
3801
|
const { plugin, pluginManager, mode } = useApp();
|
|
3802
3802
|
const { name } = useSchema();
|
|
3803
3803
|
if (mode === "single") {
|
|
@@ -3929,5 +3929,5 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
3929
3929
|
*/
|
|
3930
3930
|
|
|
3931
3931
|
export { Oas, Operation, Schema, SchemaGenerator, isKeyword, require_jsx_runtime, schemaKeywords, useSchema };
|
|
3932
|
-
//# sourceMappingURL=chunk-
|
|
3933
|
-
//# sourceMappingURL=chunk-
|
|
3932
|
+
//# sourceMappingURL=chunk-M3V3WMCW.js.map
|
|
3933
|
+
//# sourceMappingURL=chunk-M3V3WMCW.js.map
|