"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _chunkWGN7DKLRcjs = require('./chunk-WGN7DKLR.cjs'); // src/plugin.ts var _path = require('path'); var _path2 = _interopRequireDefault(_path); var _core = require('@kubb/core'); var _transformers = require('@kubb/core/transformers'); var _utils = require('@kubb/core/utils'); var _pluginoas = require('@kubb/plugin-oas'); var _utils3 = require('@kubb/plugin-oas/utils'); // src/OperationGenerator.tsx var _components = require('@kubb/plugin-oas/components'); var _react = require('@kubb/react'); var _jsxruntime = require('@kubb/react/jsx-runtime'); var OperationGenerator = class extends _pluginoas.OperationGenerator { async all(operations, _operationsByMethod) { const { pluginManager, oas, plugin, mode } = this.context; const root = _react.createRoot.call(void 0, { logger: pluginManager.logger }); const templates = { operations: _chunkWGN7DKLRcjs.Operations.templates, client: _chunkWGN7DKLRcjs.Client.templates, ...this.options.templates }; root.render( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas, { oas, operations, generator: this, children: templates.operations && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWGN7DKLRcjs.Operations.File, { baseURL: this.options.baseURL, templates: templates.operations }) }) }) ); return root.files; } async operation(operation, options) { const { oas, pluginManager, plugin, mode } = this.context; const root = _react.createRoot.call(void 0, { logger: pluginManager.logger }); const templates = { operations: _chunkWGN7DKLRcjs.Operations.templates, client: _chunkWGN7DKLRcjs.Client.templates, ...options.templates }; if (!templates.client) { return []; } root.render( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas, { oas, operations: [operation], generator: this, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas.Operation, { operation, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWGN7DKLRcjs.Client.File, { baseURL: this.options.baseURL, templates: templates.client }) }) }) }) ); return root.files; } }; // src/plugin.ts var pluginClientName = "plugin-client"; var pluginClient = _core.createPlugin.call(void 0, (options) => { const { output = { path: "clients" }, group, exclude = [], include, override = [], transformers = {}, dataReturnType = "data", pathParamsType = "inline", templates } = options; const template = _optionalChain([group, 'optionalAccess', _ => _.output]) ? group.output : `${output.path}/{{tag}}Controller`; return { name: pluginClientName, options: { extName: output.extName, dataReturnType, client: { importPath: "@kubb/swagger-client/client", ...options.client }, pathParamsType, templates: { operations: _chunkWGN7DKLRcjs.Operations.templates, client: _chunkWGN7DKLRcjs.Client.templates, ...templates }, baseURL: void 0 }, pre: [_pluginoas.pluginOasName], resolvePath(baseName, pathMode, options2) { const root = _path2.default.resolve(this.config.root, this.config.output.path); const mode = _nullishCoalesce(pathMode, () => ( _core.FileManager.getMode(_path2.default.resolve(root, output.path)))); if (mode === "single") { return _path2.default.resolve(root, output.path); } if (_optionalChain([options2, 'optionalAccess', _2 => _2.tag]) && _optionalChain([group, 'optionalAccess', _3 => _3.type]) === "tag") { const tag = _transformers.camelCase.call(void 0, options2.tag); return _path2.default.resolve(root, _utils.renderTemplate.call(void 0, template, { tag }), baseName); } return _path2.default.resolve(root, output.path, baseName); }, resolveName(name, type) { const resolvedName = _transformers.camelCase.call(void 0, name, { isFile: type === "file" }); if (type) { return _optionalChain([transformers, 'optionalAccess', _4 => _4.name, 'optionalCall', _5 => _5(resolvedName, type)]) || resolvedName; } return resolvedName; }, async writeFile(path2, source) { if (!source) { return; } return this.fileManager.write(path2, source, { sanity: false }); }, async buildStart() { const [swaggerPlugin] = _core.PluginManager.getDependedPlugins(this.plugins, [_pluginoas.pluginOasName]); const oas = await swaggerPlugin.api.getOas(); const root = _path2.default.resolve(this.config.root, this.config.output.path); const mode = _core.FileManager.getMode(_path2.default.resolve(root, output.path)); const baseURL = await swaggerPlugin.api.getBaseURL(); const operationGenerator = new OperationGenerator( { ...this.plugin.options, baseURL }, { oas, pluginManager: this.pluginManager, plugin: this.plugin, contentType: swaggerPlugin.api.contentType, exclude, include, override, mode } ); const files = await operationGenerator.build(); await this.addFile(...files); }, async buildEnd() { if (this.config.output.write === false) { return; } const root = _path2.default.resolve(this.config.root, this.config.output.path); if (_optionalChain([group, 'optionalAccess', _6 => _6.type]) === "tag") { const rootFiles = await _utils3.getGroupedByTagFiles.call(void 0, { logger: this.logger, files: this.fileManager.files, plugin: this.plugin, template, exportAs: group.exportAs || "{{tag}}Service", root, output }); await this.addFile(...rootFiles); } await this.fileManager.addIndexes({ root, output, meta: { pluginKey: this.plugin.key }, logger: this.logger }); } }; }); // src/index.ts var definePluginDefault = pluginClient; var definePlugin = pluginClient; var src_default = definePluginDefault; exports.default = src_default; exports.definePlugin = definePlugin; exports.pluginClient = pluginClient; exports.pluginClientName = pluginClientName; //# sourceMappingURL=index.cjs.map