@kubb/plugin-zod 3.0.0-alpha.8 → 3.0.0-alpha.9

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.
@@ -2850,7 +2850,11 @@ var zodKeywordMapper = {
2850
2850
  return [coercion ? "z.coerce.number()" : "z.number()", min !== void 0 ? `.min(${min})` : void 0, max !== void 0 ? `.max(${max})` : void 0].filter(Boolean).join("");
2851
2851
  },
2852
2852
  integer: (coercion, min, max) => {
2853
- return [coercion ? "z.coerce.number()" : "z.number()", min !== void 0 ? `.min(${min})` : void 0, max !== void 0 ? `.max(${max})` : void 0].filter(Boolean).join("");
2853
+ return [
2854
+ coercion ? "z.coerce.number().int()" : "z.number().int()",
2855
+ min !== void 0 ? `.min(${min})` : void 0,
2856
+ max !== void 0 ? `.max(${max})` : void 0
2857
+ ].filter(Boolean).join("");
2854
2858
  },
2855
2859
  object: (value) => `z.object({${value}})`,
2856
2860
  string: (coercion, min, max) => {
@@ -3070,9 +3074,12 @@ function parse2(parent, current, options) {
3070
3074
  if (_pluginoas.isKeyword.call(void 0, current, _pluginoas.schemaKeywords.string)) {
3071
3075
  return zodKeywordMapper.string(options.coercion);
3072
3076
  }
3073
- if (_pluginoas.isKeyword.call(void 0, current, _pluginoas.schemaKeywords.number) || _pluginoas.isKeyword.call(void 0, current, _pluginoas.schemaKeywords.integer)) {
3077
+ if (_pluginoas.isKeyword.call(void 0, current, _pluginoas.schemaKeywords.number)) {
3074
3078
  return zodKeywordMapper.number(options.coercion);
3075
3079
  }
3080
+ if (_pluginoas.isKeyword.call(void 0, current, _pluginoas.schemaKeywords.integer)) {
3081
+ return zodKeywordMapper.integer(options.coercion);
3082
+ }
3076
3083
  if (_pluginoas.isKeyword.call(void 0, current, _pluginoas.schemaKeywords.min)) {
3077
3084
  return zodKeywordMapper.min(current.args);
3078
3085
  }
@@ -3110,6 +3117,46 @@ init_cjs_shims();
3110
3117
  init_cjs_shims();
3111
3118
 
3112
3119
 
3120
+ // src/components/OperationSchema.tsx
3121
+ init_cjs_shims();
3122
+
3123
+
3124
+
3125
+
3126
+
3127
+ function OperationSchema2({ description, keysToOmit }) {
3128
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Schema2, { keysToOmit, withTypeAnnotation: false, description });
3129
+ }
3130
+ OperationSchema2.File = function({}) {
3131
+ const { pluginManager, plugin, mode } = _react.useApp.call(void 0, );
3132
+ const { getSchemas, getFile } = _hooks.useOperationManager.call(void 0, );
3133
+ const oas = _hooks.useOas.call(void 0, );
3134
+ const operation = _hooks.useOperation.call(void 0, );
3135
+ const file = getFile(operation);
3136
+ const schemas = getSchemas(operation);
3137
+ const generator = new (0, _pluginoas.SchemaGenerator)(plugin.options, {
3138
+ oas,
3139
+ plugin,
3140
+ pluginManager,
3141
+ mode,
3142
+ override: plugin.options.override
3143
+ });
3144
+ const items = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
3145
+ const mapItem = ({ name, schema, description, keysToOmit, ...options }, i) => {
3146
+ const required = Array.isArray(_optionalChain([schema, 'optionalAccess', _59 => _59.required])) ? !!schema.required.length : !!_optionalChain([schema, 'optionalAccess', _60 => _60.required]);
3147
+ const optional = !required && !!name.includes("Params");
3148
+ const tree = generator.parse({ schema, name });
3149
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _components.Oas.Schema, { name, value: schema, tree: [...tree, optional ? { keyword: _pluginoas.schemaKeywords.optional } : void 0].filter(Boolean), children: [
3150
+ mode === "split" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas.Schema.Imports, { isTypeOnly: false }),
3151
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, OperationSchema2, { description, keysToOmit })
3152
+ ] }, i);
3153
+ };
3154
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
3155
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["z"], path: plugin.options.importPath }),
3156
+ items.map(mapItem)
3157
+ ] });
3158
+ };
3159
+
3113
3160
  // src/components/Operations.tsx
3114
3161
  init_cjs_shims();
3115
3162
 
@@ -3155,9 +3202,9 @@ function RootTemplate({ children }) {
3155
3202
  const { groupSchemasByName } = _hooks.useOperationManager.call(void 0, );
3156
3203
  const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: "function" }) }));
3157
3204
  const file = pluginManager.getFile({ name: "operations", extName: ".ts", pluginKey });
3158
- const imports = Object.entries(transformedOperations).map(([_key, { data, operation }], index) => {
3205
+ const imports = Object.entries(transformedOperations).map(([key, { data, operation }]) => {
3159
3206
  const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean);
3160
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: names, root: file.path, path: getFile(operation).path }, index);
3207
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: names, root: file.path, path: getFile(operation).path }, key);
3161
3208
  }).filter(Boolean);
3162
3209
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
3163
3210
  mode === "split" && imports,
@@ -3177,49 +3224,9 @@ Operations.File = function(props) {
3177
3224
  };
3178
3225
  Operations.templates = defaultTemplates2;
3179
3226
 
3180
- // src/components/OperationSchema.tsx
3181
- init_cjs_shims();
3182
-
3183
-
3184
-
3185
-
3186
-
3187
- function OperationSchema2({ description, keysToOmit }) {
3188
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Schema2, { keysToOmit, withTypeAnnotation: false, description });
3189
- }
3190
- OperationSchema2.File = function({}) {
3191
- const { pluginManager, plugin, mode } = _react.useApp.call(void 0, );
3192
- const { getSchemas, getFile } = _hooks.useOperationManager.call(void 0, );
3193
- const oas = _hooks.useOas.call(void 0, );
3194
- const operation = _hooks.useOperation.call(void 0, );
3195
- const file = getFile(operation);
3196
- const schemas = getSchemas(operation);
3197
- const generator = new (0, _pluginoas.SchemaGenerator)(plugin.options, {
3198
- oas,
3199
- plugin,
3200
- pluginManager,
3201
- mode,
3202
- override: plugin.options.override
3203
- });
3204
- const items = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
3205
- const mapItem = ({ name, schema, description, keysToOmit, ...options }, i) => {
3206
- const required = Array.isArray(_optionalChain([schema, 'optionalAccess', _59 => _59.required])) ? !!schema.required.length : !!_optionalChain([schema, 'optionalAccess', _60 => _60.required]);
3207
- const optional = !required && !!name.includes("Params");
3208
- const tree = generator.parse({ schema, name });
3209
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _components.Oas.Schema, { name, value: schema, tree: [...tree, optional ? { keyword: _pluginoas.schemaKeywords.optional } : void 0].filter(Boolean), children: [
3210
- mode === "split" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas.Schema.Imports, { isTypeOnly: false }),
3211
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, OperationSchema2, { description, keysToOmit })
3212
- ] }, i);
3213
- };
3214
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
3215
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["z"], path: plugin.options.importPath }),
3216
- items.map(mapItem)
3217
- ] });
3218
- };
3219
-
3220
3227
  // src/SchemaGenerator.tsx
3221
3228
 
3222
- var zodParser = _pluginoas.createReactParser.call(void 0, {
3229
+ var zodParser = _pluginoas.createReactGenerator.call(void 0, {
3223
3230
  name: "plugin-zod",
3224
3231
  Operations({ options }) {
3225
3232
  if (!options.templates.operations) {
@@ -3467,7 +3474,7 @@ Schema2.Imports = () => {
3467
3474
 
3468
3475
 
3469
3476
 
3470
- exports.init_cjs_shims = init_cjs_shims; exports.Schema = Schema2; exports.Operations = Operations; exports.OperationSchema = OperationSchema2; exports.pluginZodName = pluginZodName; exports.pluginZod = pluginZod;
3477
+ exports.init_cjs_shims = init_cjs_shims; exports.Schema = Schema2; exports.OperationSchema = OperationSchema2; exports.Operations = Operations; exports.pluginZodName = pluginZodName; exports.pluginZod = pluginZod;
3471
3478
  /*! Bundled license information:
3472
3479
 
3473
3480
  react/cjs/react.production.min.js:
@@ -3492,4 +3499,4 @@ react/cjs/react.development.js:
3492
3499
  * LICENSE file in the root directory of this source tree.
3493
3500
  *)
3494
3501
  */
3495
- //# sourceMappingURL=chunk-TSJ74266.cjs.map
3502
+ //# sourceMappingURL=chunk-57AHBVYK.cjs.map