Skip to content

Commit

Permalink
chore: upgrade packages
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle committed Dec 14, 2024
1 parent 9399093 commit a3573f4
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 135 deletions.
2 changes: 1 addition & 1 deletion packages/config-tsup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
},
"dependencies": {
"@microsoft/api-extractor": "^7.48.0"
"@microsoft/api-extractor": "^7.48.1"
},
"devDependencies": {
"@kubb/config-ts": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/parser-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
},
"dependencies": {
"remeda": "^2.17.4",
"prettier": "^3.4.2",
"remeda": "^2.17.4",
"typescript": "catalog:"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-faker/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import transformers from '@kubb/core/transformers'
import { SchemaGenerator, type SchemaTree, isKeyword, schemaKeywords } from '@kubb/plugin-oas'

import type { Schema, SchemaKeywordBase, SchemaKeywordMapper, SchemaMapper } from '@kubb/plugin-oas'
import type { Options } from '../types.ts'
import type { Options } from './types.ts'

const fakerKeywordMapper = {
any: () => 'undefined',
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@kubb/config-tsup": "workspace:*",
"zod": "~3.24.1",
"tsup": "^8.3.5"
"tsup": "catalog:",
"zod": "~3.24.1"
},
"peerDependencies": {
"@kubb/react": "^3.0.0"
Expand Down
49 changes: 4 additions & 45 deletions packages/plugin-zod/src/utils/ToZod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ type IsOptional<T> = Extract<T, undefined> extends never ? false : true

type ZodWithEffects<T> = T | ZodType<T> | ZodDefault<T extends ZodType ? T : ZodType<T>> | ZodEffects<T extends ZodType ? T : ZodType<T>, any, any>

/**
* See https://github.com/colinhacks/tozod/blob/master/src/index.ts
* Adapted based on https://github.com/colinhacks/zod/issues/372
*/
export type ToZod<T> = T extends any[]
? ZodArray<ToZod<T[number]>>
: T extends Record<string, any> // object
Expand All @@ -22,48 +26,3 @@ type ToZodSchemaPrimitive<T> = IsNullable<T> extends true
: IsOptional<T> extends true
? ZodWithEffects<ZodOptional<ZodType<Exclude<T, undefined>>>> | ZodWithEffects<ZodDefault<ZodType<Exclude<T, undefined>>>>
: ZodWithEffects<T>

// type isAny<T> = [any extends T ? 'true' : 'false'] extends ['true'] ? true : false
// type nonoptional<T> = T extends undefined ? never : T
// type nonnullable<T> = T extends null ? never : T
// type equals<X, Y> = [X] extends [Y] ? ([Y] extends [X] ? true : false) : false
//
// /**
// * See https://github.com/colinhacks/tozod/blob/master/src/index.ts
// * Adapted based on https://github.com/colinhacks/zod/issues/372
// */
// export type toZod<T> = {
// any: z.ZodAny
// optional: z.ZodUnion<[toZod<nonoptional<T>>, z.ZodUndefined]>
// nullable: z.ZodUnion<[toZod<nonnullable<T>>, z.ZodNull]>
// array: T extends Array<infer U> ? z.ZodArray<toZod<U>> : never
// string: z.ZodString
// bigint: z.ZodBigInt
// number: z.ZodNumber
// boolean: z.ZodBoolean
// date: z.ZodDate
// object: z.ZodObject<{ [k in keyof T]: toZod<T[k]> }, 'strict', Extract<T, z.ZodTypeAny>>
// rest: never
// }[zodKey<T>]
//
// type zodKey<T> = isAny<T> extends true
// ? 'any'
// : equals<T, boolean> extends true //[T] extends [booleanUtil.Type]
// ? 'boolean'
// : [undefined] extends [T]
// ? 'optional'
// : [null] extends [T]
// ? 'nullable'
// : T extends any[]
// ? 'array'
// : equals<T, string> extends true
// ? 'string'
// : equals<T, bigint> extends true //[T] extends [bigintUtil.Type]
// ? 'bigint'
// : equals<T, number> extends true //[T] extends [numberUtil.Type]
// ? 'number'
// : equals<T, Date> extends true //[T] extends [dateUtil.Type]
// ? 'date'
// : T extends { [k: string]: any } //[T] extends [structUtil.Type]
// ? 'object'
// : 'rest'
Loading

0 comments on commit a3573f4

Please sign in to comment.