@kubb/plugin-ts 3.0.0-alpha.6 → 3.0.0-alpha.8

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.
@@ -2,13 +2,13 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkYUTLPFP7cjs = require('./chunk-YUTLPFP7.cjs');
5
+ var _chunkSEH6NUCXcjs = require('./chunk-SEH6NUCX.cjs');
6
6
 
7
7
  // ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
8
- var require_react_production_min = _chunkYUTLPFP7cjs.__commonJS.call(void 0, {
8
+ var require_react_production_min = _chunkSEH6NUCXcjs.__commonJS.call(void 0, {
9
9
  "../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js"(exports) {
10
10
  "use strict";
11
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
11
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
12
12
  var l = Symbol.for("react.element");
13
13
  var n = Symbol.for("react.portal");
14
14
  var p = Symbol.for("react.fragment");
@@ -279,10 +279,10 @@ var require_react_production_min = _chunkYUTLPFP7cjs.__commonJS.call(void 0, {
279
279
  });
280
280
 
281
281
  // ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.development.js
282
- var require_react_development = _chunkYUTLPFP7cjs.__commonJS.call(void 0, {
282
+ var require_react_development = _chunkSEH6NUCXcjs.__commonJS.call(void 0, {
283
283
  "../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.development.js"(exports, module) {
284
284
  "use strict";
285
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
285
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
286
286
  if (process.env.NODE_ENV !== "production") {
287
287
  (function() {
288
288
  "use strict";
@@ -2154,10 +2154,10 @@ var require_react_development = _chunkYUTLPFP7cjs.__commonJS.call(void 0, {
2154
2154
  });
2155
2155
 
2156
2156
  // ../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js
2157
- var require_react = _chunkYUTLPFP7cjs.__commonJS.call(void 0, {
2157
+ var require_react = _chunkSEH6NUCXcjs.__commonJS.call(void 0, {
2158
2158
  "../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"(exports, module) {
2159
2159
  "use strict";
2160
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
2160
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
2161
2161
  if (process.env.NODE_ENV === "production") {
2162
2162
  module.exports = require_react_production_min();
2163
2163
  } else {
@@ -2167,10 +2167,10 @@ var require_react = _chunkYUTLPFP7cjs.__commonJS.call(void 0, {
2167
2167
  });
2168
2168
 
2169
2169
  // src/index.ts
2170
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
2170
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
2171
2171
 
2172
2172
  // src/plugin.ts
2173
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
2173
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
2174
2174
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
2175
2175
  var _core = require('@kubb/core');
2176
2176
  var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
@@ -2178,21 +2178,21 @@ var _utils = require('@kubb/core/utils');
2178
2178
  var _pluginoas = require('@kubb/plugin-oas');
2179
2179
 
2180
2180
  // src/OperationGenerator.tsx
2181
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
2181
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
2182
2182
 
2183
2183
  var _components = require('@kubb/plugin-oas/components');
2184
2184
  var _react = require('@kubb/react');
2185
2185
 
2186
2186
  // src/components/OasType.tsx
2187
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
2188
-
2187
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
2189
2188
  var _hooks = require('@kubb/plugin-oas/hooks');
2189
+
2190
2190
  var _jsxruntime = require('@kubb/react/jsx-runtime');
2191
2191
  function Template({ name, typeName, api }) {
2192
2192
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
2193
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, children: `export const ${name} = ${JSON.stringify(api, void 0, 2)} as const` }),
2193
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, isIndexable: true, children: `export const ${name} = ${JSON.stringify(api, void 0, 2)} as const` }),
2194
2194
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "br", {}),
2195
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: typeName, isExportable: true, isTypeOnly: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: typeName, export: true, children: `Infer<typeof ${name}>` }) })
2195
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: typeName, export: true, children: `Infer<typeof ${name}>` }) })
2196
2196
  ] });
2197
2197
  }
2198
2198
  var defaultTemplates = { default: Template };
@@ -2215,7 +2215,7 @@ OasType.File = function({ name, typeName, templates = defaultTemplates }) {
2215
2215
  OasType.templates = defaultTemplates;
2216
2216
 
2217
2217
  // src/components/OperationSchema.tsx
2218
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
2218
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
2219
2219
 
2220
2220
  var _parserts = require('@kubb/parser-ts');
2221
2221
  var _factory = require('@kubb/parser-ts/factory'); var factory3 = _interopRequireWildcard(_factory); var factory2 = _interopRequireWildcard(_factory); var factory = _interopRequireWildcard(_factory);
@@ -2224,14 +2224,14 @@ var _factory = require('@kubb/parser-ts/factory'); var factory3 = _interopRequir
2224
2224
 
2225
2225
 
2226
2226
  // src/SchemaGenerator.tsx
2227
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
2227
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
2228
2228
 
2229
2229
 
2230
2230
 
2231
2231
 
2232
2232
  // src/components/Schema.tsx
2233
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
2234
- var import_react3 = _chunkYUTLPFP7cjs.__toESM.call(void 0, require_react(), 1);
2233
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
2234
+ var import_react3 = _chunkSEH6NUCXcjs.__toESM.call(void 0, require_react(), 1);
2235
2235
 
2236
2236
 
2237
2237
 
@@ -2241,7 +2241,7 @@ var import_react3 = _chunkYUTLPFP7cjs.__toESM.call(void 0, require_react(), 1);
2241
2241
 
2242
2242
 
2243
2243
  // src/parser/index.ts
2244
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
2244
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
2245
2245
 
2246
2246
 
2247
2247
 
@@ -2450,6 +2450,9 @@ function Schema(props) {
2450
2450
  options: { mapper, enumType, optionalType }
2451
2451
  }
2452
2452
  } = _react.useApp.call(void 0, );
2453
+ if (enumType === "asPascalConst") {
2454
+ pluginManager.logger.emit("warning", `enumType '${enumType}' is deprecated`);
2455
+ }
2453
2456
  const resolvedName = pluginManager.resolveName({
2454
2457
  name,
2455
2458
  pluginKey: [pluginTsName],
@@ -2504,7 +2507,7 @@ function Schema(props) {
2504
2507
  });
2505
2508
  const enumSchemas = _pluginoas.SchemaGenerator.deepSearch(tree, _pluginoas.schemaKeywords.enum);
2506
2509
  const enums = enumSchemas.map((enumSchema) => {
2507
- const name2 = _transformers2.default.camelCase(enumSchema.args.name);
2510
+ const name2 = enumType === "asPascalConst" ? _transformers2.default.pascalCase(enumSchema.args.name) : _transformers2.default.camelCase(enumSchema.args.name);
2508
2511
  const typeName2 = enumSchema.args.typeName;
2509
2512
  const [nameNode, typeNode] = factory2.createEnumDeclaration({
2510
2513
  name: name2,
@@ -2527,16 +2530,16 @@ function Schema(props) {
2527
2530
  );
2528
2531
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, import_react3.Fragment, { children: [
2529
2532
  enums.map(({ name: name2, nameNode, typeName: typeName2, typeNode }, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, import_react3.Fragment, { children: [
2530
- nameNode && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: name2, isExportable: true, children: _parserts.print.call(void 0, nameNode) }),
2531
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: typeName2, isExportable: true, isTypeOnly: true, children: _parserts.print.call(void 0, typeNode) })
2532
- ] }, index)),
2533
- enums.every((item) => item.typeName !== resolvedName) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: typeName, isTypeOnly: true, isExportable: true, children: _parserts.print.call(void 0, typeNodes) })
2533
+ nameNode && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: name2, isExportable: true, isIndexable: true, children: _parserts.print.call(void 0, nameNode) }),
2534
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: typeName2, isIndexable: true, isExportable: ["enum", "asConst", "constEnum", "literal", void 0].includes(enumType), isTypeOnly: true, children: _parserts.print.call(void 0, typeNode) })
2535
+ ] }, [name2, nameNode].join("-"))),
2536
+ enums.every((item) => item.typeName !== resolvedName) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: typeName, isTypeOnly: true, isExportable: true, isIndexable: true, children: _parserts.print.call(void 0, typeNodes) })
2534
2537
  ] });
2535
2538
  }
2536
2539
  Schema.File = function({}) {
2537
2540
  const { pluginManager } = _react.useApp.call(void 0, );
2538
2541
  const { schema } = _hooks.useSchema.call(void 0, );
2539
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas.Schema.File, { output: pluginManager.config.output.path, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Schema, { description: _optionalChain([schema, 'optionalAccess', _23 => _23.description]) }) });
2542
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas.Schema.File, { isTypeOnly: true, output: pluginManager.config.output.path, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Schema, { description: _optionalChain([schema, 'optionalAccess', _23 => _23.description]) }) });
2540
2543
  };
2541
2544
 
2542
2545
  // src/SchemaGenerator.tsx
@@ -2617,7 +2620,7 @@ function printCombinedSchema({
2617
2620
  });
2618
2621
  }
2619
2622
  const namespaceNode = factory3.createTypeAliasDeclaration({
2620
- name: operation.method === "get" ? `${name}Query` : `${name}Mutation`,
2623
+ name,
2621
2624
  type: factory3.createTypeLiteralNode(
2622
2625
  Object.keys(properties).map((key) => {
2623
2626
  const type = properties[key];
@@ -2660,9 +2663,10 @@ OperationSchema.File = function({}) {
2660
2663
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, OperationSchema, { description, keysToOmit })
2661
2664
  ] }, i);
2662
2665
  };
2666
+ const combinedSchemaName = operation.method === "get" ? `${factoryName}Query` : `${factoryName}Mutation`;
2663
2667
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
2664
2668
  items.map(mapItem),
2665
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: factoryName, isExportable: true, children: printCombinedSchema({ name: factoryName, operation, schemas, pluginManager }) })
2669
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: combinedSchemaName, isExportable: true, isIndexable: true, isTypeOnly: true, children: printCombinedSchema({ name: combinedSchemaName, operation, schemas, pluginManager }) })
2666
2670
  ] });
2667
2671
  };
2668
2672
 
@@ -2712,6 +2716,10 @@ var pluginTs = _core.createPlugin.call(void 0, (options) => {
2712
2716
  const template = _optionalChain([group, 'optionalAccess', _24 => _24.output]) ? group.output : `${output.path}/{{tag}}Controller`;
2713
2717
  return {
2714
2718
  name: pluginTsName,
2719
+ output: {
2720
+ exportType: "barrelNamed",
2721
+ ...output
2722
+ },
2715
2723
  options: {
2716
2724
  extName: output.extName,
2717
2725
  transformers: transformers4,
@@ -2775,15 +2783,17 @@ var pluginTs = _core.createPlugin.call(void 0, (options) => {
2775
2783
  });
2776
2784
  const operationFiles = await operationGenerator.build();
2777
2785
  await this.addFile(...operationFiles);
2778
- if (this.config.output.write) {
2779
- const indexFiles = await this.fileManager.getIndexFiles({
2786
+ if (this.config.output.exportType) {
2787
+ const barrelFiles = await this.fileManager.getBarrelFiles({
2780
2788
  root,
2781
2789
  output,
2782
2790
  files: this.fileManager.files,
2783
- plugin: this.plugin,
2791
+ meta: {
2792
+ pluginKey: this.plugin.key
2793
+ },
2784
2794
  logger: this.logger
2785
2795
  });
2786
- await this.addFile(...indexFiles);
2796
+ await this.addFile(...barrelFiles);
2787
2797
  }
2788
2798
  }
2789
2799
  };
@@ -2820,4 +2830,4 @@ react/cjs/react.development.js:
2820
2830
  * LICENSE file in the root directory of this source tree.
2821
2831
  *)
2822
2832
  */
2823
- //# sourceMappingURL=chunk-QBRUTU67.cjs.map
2833
+ //# sourceMappingURL=chunk-PV5Q7I5O.cjs.map