Comparing version 0.0.12 to 0.0.13
@@ -1,4 +0,5 @@ | ||
import { PascalCase } from "type-fest"; | ||
import type { PascalCase } from "type-fest"; | ||
import { ParseParams, SafeParseReturnType, ZodArray, ZodFunction, ZodIntersection, ZodLazy, ZodMap, ZodNullable, ZodObject, ZodOptional, ZodPromise, ZodRawShape, ZodRecord, ZodSet, ZodTuple, ZodType, ZodTypeAny, ZodUnion, z } from "zod"; | ||
type Ctor<T = any> = { | ||
[key: string]: any; | ||
new (input: any): T; | ||
@@ -8,2 +9,3 @@ }; | ||
shape: Shape; | ||
staticProps: StaticProperties<Shape>; | ||
pick<Mask extends keyof Shape>(...mask: Mask[]): Z.Class<Pick<Shape, Mask>>; | ||
@@ -22,5 +24,5 @@ pick<Mask extends { | ||
schema<T>(this: Ctor<T>): z.ZodType<T>; | ||
extend<Super extends Ctor, ChildShape extends ZodRawShape>(this: Super, shape: ChildShape): StaticProperties<ChildShape> & { | ||
[k in keyof Super]: Super[k]; | ||
} & ZodClass<Z.infer<ZodObject<ChildShape>> & ConstructorParameters<Super>[0], Z.infer<ZodObject<ChildShape>> & InstanceType<Super>, Omit<Shape, keyof ChildShape> & ChildShape>; | ||
extend<Super extends Ctor, ChildShape extends ZodRawShape>(this: Super, shape: ChildShape): StaticProperties<ChildShape> & ({ | ||
[k in Exclude<keyof Super, keyof z.ZodObject<any>>]: Super[k]; | ||
}) & ZodClass<Z.infer<ZodObject<ChildShape>> & ConstructorParameters<Super>[0], Z.infer<ZodObject<ChildShape>> & InstanceType<Super>, Omit<Shape, keyof ChildShape> & ChildShape>; | ||
optional<Self extends ZodTypeAny>(this: Self): ZodOptional<Self>; | ||
@@ -49,3 +51,3 @@ nullable<Self extends ZodTypeAny>(this: Self): ZodNullable<Self>; | ||
} : T extends ZodRecord<infer Key, infer Value> ? { | ||
[k in Z.infer<Key>]: Z.infer<Value>; | ||
[k in Extract<Z.infer<Key>, string | number | symbol>]: Z.infer<Value>; | ||
} : T extends ZodMap<infer Key, infer Value> ? Map<Z.infer<Key>, Z.infer<Value>> : T extends ZodSet<infer Item> ? Set<Z.infer<Item>> : T extends ZodFunction<infer Args, infer Output> ? (...args: Z.infer<Args>) => Z.infer<Output> : T extends ZodLazy<infer T> ? Z.infer<T> : T extends ZodPromise<infer T> ? Promise<Z.infer<T>> : T extends ZodType<any, any, any> ? z.infer<T> : never; | ||
@@ -56,5 +58,2 @@ } | ||
}; | ||
export interface Z { | ||
class<Shape extends ZodRawShape>(shape: Shape): Z.Class<Shape>; | ||
} | ||
export declare namespace Z { | ||
@@ -64,5 +63,5 @@ type Class<Shape extends ZodRawShape> = StaticProperties<Shape> & ZodClass<Z.infer<ZodObject<Shape>>, Z.infer<ZodObject<Shape>>, Shape>; | ||
export declare const Z: { | ||
class<T extends ZodRawShape>(shape: T): { [property in keyof T as PascalCase<property>]: T[property]; } & ZodClass<{ [k in keyof T]: Z.infer<T[k]>; }, { [k_1 in keyof Pick<T, Exclude<keyof T, OptionalKeys<T>>>]: Z.infer<T[k_1]>; } & { [k_2 in OptionalKeys<T>]+?: Z.infer<T[k_2]>; }, T>; | ||
class<T extends ZodRawShape>(shape: T): Z.Class<T>; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -10,3 +10,3 @@ "use strict"; | ||
const to_pascal_case_js_1 = require("./to-pascal-case.js"); | ||
const types_1 = require("util/types"); | ||
const types_1 = require("node:util/types"); | ||
const IS_ZOD_CLASS = Symbol.for("zod-class"); | ||
@@ -13,0 +13,0 @@ exports.Z = { |
@@ -1,4 +0,5 @@ | ||
import { PascalCase } from "type-fest"; | ||
import type { PascalCase } from "type-fest"; | ||
import { ParseParams, SafeParseReturnType, ZodArray, ZodFunction, ZodIntersection, ZodLazy, ZodMap, ZodNullable, ZodObject, ZodOptional, ZodPromise, ZodRawShape, ZodRecord, ZodSet, ZodTuple, ZodType, ZodTypeAny, ZodUnion, z } from "zod"; | ||
type Ctor<T = any> = { | ||
[key: string]: any; | ||
new (input: any): T; | ||
@@ -8,2 +9,3 @@ }; | ||
shape: Shape; | ||
staticProps: StaticProperties<Shape>; | ||
pick<Mask extends keyof Shape>(...mask: Mask[]): Z.Class<Pick<Shape, Mask>>; | ||
@@ -22,5 +24,5 @@ pick<Mask extends { | ||
schema<T>(this: Ctor<T>): z.ZodType<T>; | ||
extend<Super extends Ctor, ChildShape extends ZodRawShape>(this: Super, shape: ChildShape): StaticProperties<ChildShape> & { | ||
[k in keyof Super]: Super[k]; | ||
} & ZodClass<Z.infer<ZodObject<ChildShape>> & ConstructorParameters<Super>[0], Z.infer<ZodObject<ChildShape>> & InstanceType<Super>, Omit<Shape, keyof ChildShape> & ChildShape>; | ||
extend<Super extends Ctor, ChildShape extends ZodRawShape>(this: Super, shape: ChildShape): StaticProperties<ChildShape> & ({ | ||
[k in Exclude<keyof Super, keyof z.ZodObject<any>>]: Super[k]; | ||
}) & ZodClass<Z.infer<ZodObject<ChildShape>> & ConstructorParameters<Super>[0], Z.infer<ZodObject<ChildShape>> & InstanceType<Super>, Omit<Shape, keyof ChildShape> & ChildShape>; | ||
optional<Self extends ZodTypeAny>(this: Self): ZodOptional<Self>; | ||
@@ -49,3 +51,3 @@ nullable<Self extends ZodTypeAny>(this: Self): ZodNullable<Self>; | ||
} : T extends ZodRecord<infer Key, infer Value> ? { | ||
[k in Z.infer<Key>]: Z.infer<Value>; | ||
[k in Extract<Z.infer<Key>, string | number | symbol>]: Z.infer<Value>; | ||
} : T extends ZodMap<infer Key, infer Value> ? Map<Z.infer<Key>, Z.infer<Value>> : T extends ZodSet<infer Item> ? Set<Z.infer<Item>> : T extends ZodFunction<infer Args, infer Output> ? (...args: Z.infer<Args>) => Z.infer<Output> : T extends ZodLazy<infer T> ? Z.infer<T> : T extends ZodPromise<infer T> ? Promise<Z.infer<T>> : T extends ZodType<any, any, any> ? z.infer<T> : never; | ||
@@ -56,5 +58,2 @@ } | ||
}; | ||
export interface Z { | ||
class<Shape extends ZodRawShape>(shape: Shape): Z.Class<Shape>; | ||
} | ||
export declare namespace Z { | ||
@@ -64,5 +63,5 @@ type Class<Shape extends ZodRawShape> = StaticProperties<Shape> & ZodClass<Z.infer<ZodObject<Shape>>, Z.infer<ZodObject<Shape>>, Shape>; | ||
export declare const Z: { | ||
class<T extends ZodRawShape>(shape: T): { [property in keyof T as PascalCase<property>]: T[property]; } & ZodClass<{ [k in keyof T]: Z.infer<T[k]>; }, { [k_1 in keyof Pick<T, Exclude<keyof T, OptionalKeys<T>>>]: Z.infer<T[k_1]>; } & { [k_2 in OptionalKeys<T>]+?: Z.infer<T[k_2]>; }, T>; | ||
class<T extends ZodRawShape>(shape: T): Z.Class<T>; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,3 +7,3 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) { | ||
import { toPascalCase } from "./to-pascal-case.js"; | ||
import { isPromise } from "util/types"; | ||
import { isPromise } from "node:util/types"; | ||
const IS_ZOD_CLASS = Symbol.for("zod-class"); | ||
@@ -10,0 +10,0 @@ export const Z = { |
{ | ||
"name": "zod-class", | ||
"description": "Create classes from Zod Object schemas all in one line", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"repository": { | ||
@@ -24,2 +24,5 @@ "url": "https://github.com/sam-goodwin/zod-class" | ||
}, | ||
"dependencies": { | ||
"type-fest": "^4.14.0" | ||
}, | ||
"peerDependencies": { | ||
@@ -32,2 +35,3 @@ "zod": "^3" | ||
"@types/node": "^16", | ||
"bun": "^1.0.36", | ||
"jest": "^29.7.0", | ||
@@ -37,8 +41,5 @@ "prettier": "^2.8.8", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.2.2", | ||
"typescript": "^5.4.3", | ||
"zod": "3.20.2" | ||
}, | ||
"dependencies": { | ||
"type-fest": "^4.6.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
161596
10
495
Updatedtype-fest@^4.14.0