drizzle-zod 0.8.3-e450094 → 0.8.3-e6bdce6

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.
package/column.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import type { Column } from 'drizzle-orm';
1
+ import { type Column } from 'drizzle-orm';
2
2
  import { z as zod } from 'zod/v4';
3
- import type { CreateSchemaFactoryOptions } from "./schema.types.cjs";
3
+ import type { FactoryOptions } from "./schema.types.cjs";
4
4
  import type { Json } from "./utils.cjs";
5
5
  export declare const literalSchema: zod.ZodUnion<readonly [zod.ZodString, zod.ZodNumber, zod.ZodBoolean, zod.ZodNull]>;
6
6
  export declare const jsonSchema: zod.ZodType<Json>;
7
7
  export declare const bufferSchema: zod.ZodType<Buffer>;
8
- export declare function columnToSchema(column: Column, factory: CreateSchemaFactoryOptions<Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined> | undefined): zod.ZodType;
8
+ export declare function columnToSchema(column: Column, factory: FactoryOptions | undefined): zod.ZodType;
package/column.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import type { Column } from 'drizzle-orm';
1
+ import { type Column } from 'drizzle-orm';
2
2
  import { z as zod } from 'zod/v4';
3
- import type { CreateSchemaFactoryOptions } from "./schema.types.mjs";
3
+ import type { FactoryOptions } from "./schema.types.mjs";
4
4
  import type { Json } from "./utils.mjs";
5
5
  export declare const literalSchema: zod.ZodUnion<readonly [zod.ZodString, zod.ZodNumber, zod.ZodBoolean, zod.ZodNull]>;
6
6
  export declare const jsonSchema: zod.ZodType<Json>;
7
7
  export declare const bufferSchema: zod.ZodType<Buffer>;
8
- export declare function columnToSchema(column: Column, factory: CreateSchemaFactoryOptions<Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined> | undefined): zod.ZodType;
8
+ export declare function columnToSchema(column: Column, factory: FactoryOptions | undefined): zod.ZodType;
package/column.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { Column } from 'drizzle-orm';
1
+ import { type Column } from 'drizzle-orm';
2
2
  import { z as zod } from 'zod/v4';
3
- import type { CreateSchemaFactoryOptions } from './schema.types.js';
3
+ import type { FactoryOptions } from './schema.types.js';
4
4
  import type { Json } from './utils.js';
5
5
  export declare const literalSchema: zod.ZodUnion<readonly [zod.ZodString, zod.ZodNumber, zod.ZodBoolean, zod.ZodNull]>;
6
6
  export declare const jsonSchema: zod.ZodType<Json>;
7
7
  export declare const bufferSchema: zod.ZodType<Buffer>;
8
- export declare function columnToSchema(column: Column, factory: CreateSchemaFactoryOptions<Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined> | undefined): zod.ZodType;
8
+ export declare function columnToSchema(column: Column, factory: FactoryOptions | undefined): zod.ZodType;
@@ -1,23 +1,24 @@
1
- import type { Assume, Column } from 'drizzle-orm';
1
+ import type { Assume, Column, ColumnTypeData, ExtractColumnTypeData } from 'drizzle-orm';
2
2
  import type { z } from 'zod/v4';
3
- import type { IsEnumDefined, IsNever, Json } from "./utils.cjs";
4
- type HasBaseColumn<TColumn> = TColumn extends {
5
- _: {
6
- baseColumn: Column | undefined;
7
- };
8
- } ? IsNever<TColumn['_']['baseColumn']> extends false ? true : false : false;
9
- export type GetZodType<TColumn extends Column, TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined> = HasBaseColumn<TColumn> extends true ? z.ZodArray<GetZodType<Assume<TColumn['_']['baseColumn'], Column>, TCoerce>> : TColumn['_']['columnType'] extends 'PgUUID' ? z.ZodUUID : IsEnumDefined<TColumn['_']['enumValues']> extends true ? z.ZodEnum<{
10
- [K in Assume<TColumn['_']['enumValues'], [string, ...string[]]>[number]]: K;
11
- }> : TColumn['_']['columnType'] extends 'PgGeometry' | 'PgPointTuple' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber], null> : TColumn['_']['columnType'] extends 'PgLine' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null> : TColumn['_']['data'] extends Date ? CanCoerce<TCoerce, 'date'> extends true ? z.coerce.ZodCoercedDate : z.ZodDate : TColumn['_']['data'] extends Buffer ? z.ZodType<Buffer> : TColumn['_']['dataType'] extends 'array' ? z.ZodArray<GetZodPrimitiveType<Assume<TColumn['_']['data'], any[]>[number], '', TCoerce>> : TColumn['_']['data'] extends Record<string, any> ? TColumn['_']['columnType'] extends 'PgJson' | 'PgJsonb' | 'MySqlJson' | 'SingleStoreJson' | 'SQLiteTextJson' | 'SQLiteBlobJson' ? z.ZodType<TColumn['_']['data'], TColumn['_']['data']> : z.ZodObject<{
12
- [K in keyof TColumn['_']['data']]: GetZodPrimitiveType<TColumn['_']['data'][K], '', TCoerce>;
13
- }, {
14
- out: {};
15
- in: {};
16
- }> : TColumn['_']['dataType'] extends 'json' ? z.ZodType<Json> : GetZodPrimitiveType<TColumn['_']['data'], TColumn['_']['columnType'], TCoerce>;
17
- type CanCoerce<TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined, TTo extends 'bigint' | 'boolean' | 'date' | 'number' | 'string'> = TCoerce extends true ? true : TCoerce extends Record<string, any> ? TCoerce[TTo] extends true ? true : false : false;
18
- type GetZodPrimitiveType<TData, TColumnType, TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined> = TColumnType extends 'MySqlTinyInt' | 'SingleStoreTinyInt' | 'PgSmallInt' | 'PgSmallSerial' | 'MySqlSmallInt' | 'MySqlMediumInt' | 'SingleStoreSmallInt' | 'SingleStoreMediumInt' | 'PgInteger' | 'PgSerial' | 'MySqlInt' | 'SingleStoreInt' | 'PgBigInt53' | 'PgBigSerial53' | 'MySqlBigInt53' | 'MySqlSerial' | 'SingleStoreBigInt53' | 'SingleStoreSerial' | 'SQLiteInteger' | 'MySqlYear' | 'SingleStoreYear' ? CanCoerce<TCoerce, 'number'> extends true ? z.coerce.ZodCoercedNumber : z.ZodInt : TData extends number ? CanCoerce<TCoerce, 'number'> extends true ? z.coerce.ZodCoercedNumber : z.ZodNumber : TData extends bigint ? CanCoerce<TCoerce, 'bigint'> extends true ? z.coerce.ZodCoercedBigInt : z.ZodBigInt : TData extends boolean ? CanCoerce<TCoerce, 'boolean'> extends true ? z.coerce.ZodCoercedBoolean : z.ZodBoolean : TData extends string ? CanCoerce<TCoerce, 'string'> extends true ? z.coerce.ZodCoercedString : z.ZodString : z.ZodType;
3
+ import type { bigintStringModeSchema } from "./column.cjs";
4
+ import type { CoerceOptions } from "./schema.types.cjs";
5
+ import type { Json } from "./utils.cjs";
6
+ export type GetZodType<TColumn extends Column<any>, TCoerce extends CoerceOptions, TType extends ColumnTypeData = ExtractColumnTypeData<TColumn['_']['dataType']>, TCanCoerce extends boolean = CanCoerce<TCoerce, ColumnTypeDataToCoerceKey<TType>>> = TType['type'] extends 'array' ? TType['constraint'] extends 'geometry' | 'point' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber], null> : TType['constraint'] extends 'line' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null> : TType['constraint'] extends 'vector' | 'halfvector' ? z.ZodArray<z.ZodNumber> : TType['constraint'] extends 'int64vector' ? z.ZodArray<z.ZodBigInt> : TType['constraint'] extends 'basecolumn' ? z.ZodArray<GetZodType<Assume<TColumn['_'], {
7
+ baseColumn: Column<any>;
8
+ }>['baseColumn'], TCoerce>> : z.ZodArray<z.ZodAny> : TType['type'] extends 'object' ? TType['constraint'] extends 'date' ? CanCoerce<TCoerce, 'date'> extends true ? z.coerce.ZodCoercedDate : z.ZodDate : TType['constraint'] extends 'buffer' ? z.ZodType<Buffer> : TType['constraint'] extends 'point' | 'geometry' ? z.ZodObject<{
9
+ x: z.ZodNumber;
10
+ y: z.ZodNumber;
11
+ }, z.core.$strip> : TType['constraint'] extends 'line' ? z.ZodObject<{
12
+ a: z.ZodNumber;
13
+ b: z.ZodNumber;
14
+ c: z.ZodNumber;
15
+ }, z.core.$strip> : TType['constraint'] extends 'json' ? TColumn['_']['data'] extends Record<string, any> ? z.ZodType<TColumn['_']['data'], z.core.$strip> : z.ZodType<Json> : z.ZodObject<{}, z.core.$loose> : TType['type'] extends 'custom' ? z.ZodType : TType['type'] extends 'number' ? TCanCoerce extends true ? z.coerce.ZodCoercedNumber : (TType['constraint'] extends 'int8' | 'int16' | 'int24' | 'int32' | 'int53' | 'uint8' | 'uint16' | 'uint24' | 'uint32' | 'uint53' | 'year' ? z.ZodInt : z.ZodNumber) : TType['type'] extends 'bigint' ? TCanCoerce extends true ? z.coerce.ZodCoercedBigInt : z.ZodBigInt : TType['type'] extends 'boolean' ? TCanCoerce extends true ? z.coerce.ZodCoercedBoolean : z.ZodBoolean : TType['type'] extends 'string' ? TType['constraint'] extends 'uuid' ? z.ZodUUID : TCanCoerce extends true ? z.coerce.ZodCoercedString : TType['constraint'] extends 'enum' ? z.ZodEnum<{
16
+ [K in Assume<TColumn['_']['enumValues'], string[]>[number]]: K;
17
+ }> : TType['constraint'] extends 'int64' ? typeof bigintStringModeSchema : z.ZodString : z.ZodType;
18
+ type ColumnTypeDataToCoerceKey<TType extends ColumnTypeData> = TType['type'] extends 'bigint' | 'boolean' | 'number' | 'string' ? TType['type'] : TType['type'] extends 'object' ? TType['constraint'] extends 'date' ? TType['constraint'] : 'none' : 'none';
19
+ type CanCoerce<TCoerce extends CoerceOptions, TTo extends 'bigint' | 'boolean' | 'date' | 'number' | 'string' | 'none'> = TCoerce extends true ? true : TCoerce extends Record<string, any> ? TCoerce[TTo] extends true ? true : false : false;
19
20
  type HandleSelectColumn<TSchema extends z.ZodType, TColumn extends Column> = TColumn['_']['notNull'] extends true ? TSchema : z.ZodNullable<TSchema>;
20
21
  type HandleInsertColumn<TSchema extends z.ZodType, TColumn extends Column> = TColumn['_']['notNull'] extends true ? TColumn['_']['hasDefault'] extends true ? z.ZodOptional<TSchema> : TSchema : z.ZodOptional<z.ZodNullable<TSchema>>;
21
22
  type HandleUpdateColumn<TSchema extends z.ZodType, TColumn extends Column> = TColumn['_']['notNull'] extends true ? z.ZodOptional<TSchema> : z.ZodOptional<z.ZodNullable<TSchema>>;
22
- export type HandleColumn<TType extends 'select' | 'insert' | 'update', TColumn extends Column, TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined> = TType extends 'select' ? HandleSelectColumn<GetZodType<TColumn, TCoerce>, TColumn> : TType extends 'insert' ? HandleInsertColumn<GetZodType<TColumn, TCoerce>, TColumn> : TType extends 'update' ? HandleUpdateColumn<GetZodType<TColumn, TCoerce>, TColumn> : GetZodType<TColumn, TCoerce>;
23
+ export type HandleColumn<TType extends 'select' | 'insert' | 'update', TColumn extends Column, TCoerce extends CoerceOptions> = TType extends 'select' ? HandleSelectColumn<GetZodType<TColumn, TCoerce>, TColumn> : TType extends 'insert' ? HandleInsertColumn<GetZodType<TColumn, TCoerce>, TColumn> : TType extends 'update' ? HandleUpdateColumn<GetZodType<TColumn, TCoerce>, TColumn> : GetZodType<TColumn, TCoerce>;
23
24
  export {};
@@ -1,23 +1,24 @@
1
- import type { Assume, Column } from 'drizzle-orm';
1
+ import type { Assume, Column, ColumnTypeData, ExtractColumnTypeData } from 'drizzle-orm';
2
2
  import type { z } from 'zod/v4';
3
- import type { IsEnumDefined, IsNever, Json } from "./utils.mjs";
4
- type HasBaseColumn<TColumn> = TColumn extends {
5
- _: {
6
- baseColumn: Column | undefined;
7
- };
8
- } ? IsNever<TColumn['_']['baseColumn']> extends false ? true : false : false;
9
- export type GetZodType<TColumn extends Column, TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined> = HasBaseColumn<TColumn> extends true ? z.ZodArray<GetZodType<Assume<TColumn['_']['baseColumn'], Column>, TCoerce>> : TColumn['_']['columnType'] extends 'PgUUID' ? z.ZodUUID : IsEnumDefined<TColumn['_']['enumValues']> extends true ? z.ZodEnum<{
10
- [K in Assume<TColumn['_']['enumValues'], [string, ...string[]]>[number]]: K;
11
- }> : TColumn['_']['columnType'] extends 'PgGeometry' | 'PgPointTuple' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber], null> : TColumn['_']['columnType'] extends 'PgLine' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null> : TColumn['_']['data'] extends Date ? CanCoerce<TCoerce, 'date'> extends true ? z.coerce.ZodCoercedDate : z.ZodDate : TColumn['_']['data'] extends Buffer ? z.ZodType<Buffer> : TColumn['_']['dataType'] extends 'array' ? z.ZodArray<GetZodPrimitiveType<Assume<TColumn['_']['data'], any[]>[number], '', TCoerce>> : TColumn['_']['data'] extends Record<string, any> ? TColumn['_']['columnType'] extends 'PgJson' | 'PgJsonb' | 'MySqlJson' | 'SingleStoreJson' | 'SQLiteTextJson' | 'SQLiteBlobJson' ? z.ZodType<TColumn['_']['data'], TColumn['_']['data']> : z.ZodObject<{
12
- [K in keyof TColumn['_']['data']]: GetZodPrimitiveType<TColumn['_']['data'][K], '', TCoerce>;
13
- }, {
14
- out: {};
15
- in: {};
16
- }> : TColumn['_']['dataType'] extends 'json' ? z.ZodType<Json> : GetZodPrimitiveType<TColumn['_']['data'], TColumn['_']['columnType'], TCoerce>;
17
- type CanCoerce<TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined, TTo extends 'bigint' | 'boolean' | 'date' | 'number' | 'string'> = TCoerce extends true ? true : TCoerce extends Record<string, any> ? TCoerce[TTo] extends true ? true : false : false;
18
- type GetZodPrimitiveType<TData, TColumnType, TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined> = TColumnType extends 'MySqlTinyInt' | 'SingleStoreTinyInt' | 'PgSmallInt' | 'PgSmallSerial' | 'MySqlSmallInt' | 'MySqlMediumInt' | 'SingleStoreSmallInt' | 'SingleStoreMediumInt' | 'PgInteger' | 'PgSerial' | 'MySqlInt' | 'SingleStoreInt' | 'PgBigInt53' | 'PgBigSerial53' | 'MySqlBigInt53' | 'MySqlSerial' | 'SingleStoreBigInt53' | 'SingleStoreSerial' | 'SQLiteInteger' | 'MySqlYear' | 'SingleStoreYear' ? CanCoerce<TCoerce, 'number'> extends true ? z.coerce.ZodCoercedNumber : z.ZodInt : TData extends number ? CanCoerce<TCoerce, 'number'> extends true ? z.coerce.ZodCoercedNumber : z.ZodNumber : TData extends bigint ? CanCoerce<TCoerce, 'bigint'> extends true ? z.coerce.ZodCoercedBigInt : z.ZodBigInt : TData extends boolean ? CanCoerce<TCoerce, 'boolean'> extends true ? z.coerce.ZodCoercedBoolean : z.ZodBoolean : TData extends string ? CanCoerce<TCoerce, 'string'> extends true ? z.coerce.ZodCoercedString : z.ZodString : z.ZodType;
3
+ import type { bigintStringModeSchema } from "./column.mjs";
4
+ import type { CoerceOptions } from "./schema.types.mjs";
5
+ import type { Json } from "./utils.mjs";
6
+ export type GetZodType<TColumn extends Column<any>, TCoerce extends CoerceOptions, TType extends ColumnTypeData = ExtractColumnTypeData<TColumn['_']['dataType']>, TCanCoerce extends boolean = CanCoerce<TCoerce, ColumnTypeDataToCoerceKey<TType>>> = TType['type'] extends 'array' ? TType['constraint'] extends 'geometry' | 'point' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber], null> : TType['constraint'] extends 'line' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null> : TType['constraint'] extends 'vector' | 'halfvector' ? z.ZodArray<z.ZodNumber> : TType['constraint'] extends 'int64vector' ? z.ZodArray<z.ZodBigInt> : TType['constraint'] extends 'basecolumn' ? z.ZodArray<GetZodType<Assume<TColumn['_'], {
7
+ baseColumn: Column<any>;
8
+ }>['baseColumn'], TCoerce>> : z.ZodArray<z.ZodAny> : TType['type'] extends 'object' ? TType['constraint'] extends 'date' ? CanCoerce<TCoerce, 'date'> extends true ? z.coerce.ZodCoercedDate : z.ZodDate : TType['constraint'] extends 'buffer' ? z.ZodType<Buffer> : TType['constraint'] extends 'point' | 'geometry' ? z.ZodObject<{
9
+ x: z.ZodNumber;
10
+ y: z.ZodNumber;
11
+ }, z.core.$strip> : TType['constraint'] extends 'line' ? z.ZodObject<{
12
+ a: z.ZodNumber;
13
+ b: z.ZodNumber;
14
+ c: z.ZodNumber;
15
+ }, z.core.$strip> : TType['constraint'] extends 'json' ? TColumn['_']['data'] extends Record<string, any> ? z.ZodType<TColumn['_']['data'], z.core.$strip> : z.ZodType<Json> : z.ZodObject<{}, z.core.$loose> : TType['type'] extends 'custom' ? z.ZodType : TType['type'] extends 'number' ? TCanCoerce extends true ? z.coerce.ZodCoercedNumber : (TType['constraint'] extends 'int8' | 'int16' | 'int24' | 'int32' | 'int53' | 'uint8' | 'uint16' | 'uint24' | 'uint32' | 'uint53' | 'year' ? z.ZodInt : z.ZodNumber) : TType['type'] extends 'bigint' ? TCanCoerce extends true ? z.coerce.ZodCoercedBigInt : z.ZodBigInt : TType['type'] extends 'boolean' ? TCanCoerce extends true ? z.coerce.ZodCoercedBoolean : z.ZodBoolean : TType['type'] extends 'string' ? TType['constraint'] extends 'uuid' ? z.ZodUUID : TCanCoerce extends true ? z.coerce.ZodCoercedString : TType['constraint'] extends 'enum' ? z.ZodEnum<{
16
+ [K in Assume<TColumn['_']['enumValues'], string[]>[number]]: K;
17
+ }> : TType['constraint'] extends 'int64' ? typeof bigintStringModeSchema : z.ZodString : z.ZodType;
18
+ type ColumnTypeDataToCoerceKey<TType extends ColumnTypeData> = TType['type'] extends 'bigint' | 'boolean' | 'number' | 'string' ? TType['type'] : TType['type'] extends 'object' ? TType['constraint'] extends 'date' ? TType['constraint'] : 'none' : 'none';
19
+ type CanCoerce<TCoerce extends CoerceOptions, TTo extends 'bigint' | 'boolean' | 'date' | 'number' | 'string' | 'none'> = TCoerce extends true ? true : TCoerce extends Record<string, any> ? TCoerce[TTo] extends true ? true : false : false;
19
20
  type HandleSelectColumn<TSchema extends z.ZodType, TColumn extends Column> = TColumn['_']['notNull'] extends true ? TSchema : z.ZodNullable<TSchema>;
20
21
  type HandleInsertColumn<TSchema extends z.ZodType, TColumn extends Column> = TColumn['_']['notNull'] extends true ? TColumn['_']['hasDefault'] extends true ? z.ZodOptional<TSchema> : TSchema : z.ZodOptional<z.ZodNullable<TSchema>>;
21
22
  type HandleUpdateColumn<TSchema extends z.ZodType, TColumn extends Column> = TColumn['_']['notNull'] extends true ? z.ZodOptional<TSchema> : z.ZodOptional<z.ZodNullable<TSchema>>;
22
- export type HandleColumn<TType extends 'select' | 'insert' | 'update', TColumn extends Column, TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined> = TType extends 'select' ? HandleSelectColumn<GetZodType<TColumn, TCoerce>, TColumn> : TType extends 'insert' ? HandleInsertColumn<GetZodType<TColumn, TCoerce>, TColumn> : TType extends 'update' ? HandleUpdateColumn<GetZodType<TColumn, TCoerce>, TColumn> : GetZodType<TColumn, TCoerce>;
23
+ export type HandleColumn<TType extends 'select' | 'insert' | 'update', TColumn extends Column, TCoerce extends CoerceOptions> = TType extends 'select' ? HandleSelectColumn<GetZodType<TColumn, TCoerce>, TColumn> : TType extends 'insert' ? HandleInsertColumn<GetZodType<TColumn, TCoerce>, TColumn> : TType extends 'update' ? HandleUpdateColumn<GetZodType<TColumn, TCoerce>, TColumn> : GetZodType<TColumn, TCoerce>;
23
24
  export {};
package/column.types.d.ts CHANGED
@@ -1,23 +1,24 @@
1
- import type { Assume, Column } from 'drizzle-orm';
1
+ import type { Assume, Column, ColumnTypeData, ExtractColumnTypeData } from 'drizzle-orm';
2
2
  import type { z } from 'zod/v4';
3
- import type { IsEnumDefined, IsNever, Json } from './utils.js';
4
- type HasBaseColumn<TColumn> = TColumn extends {
5
- _: {
6
- baseColumn: Column | undefined;
7
- };
8
- } ? IsNever<TColumn['_']['baseColumn']> extends false ? true : false : false;
9
- export type GetZodType<TColumn extends Column, TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined> = HasBaseColumn<TColumn> extends true ? z.ZodArray<GetZodType<Assume<TColumn['_']['baseColumn'], Column>, TCoerce>> : TColumn['_']['columnType'] extends 'PgUUID' ? z.ZodUUID : IsEnumDefined<TColumn['_']['enumValues']> extends true ? z.ZodEnum<{
10
- [K in Assume<TColumn['_']['enumValues'], [string, ...string[]]>[number]]: K;
11
- }> : TColumn['_']['columnType'] extends 'PgGeometry' | 'PgPointTuple' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber], null> : TColumn['_']['columnType'] extends 'PgLine' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null> : TColumn['_']['data'] extends Date ? CanCoerce<TCoerce, 'date'> extends true ? z.coerce.ZodCoercedDate : z.ZodDate : TColumn['_']['data'] extends Buffer ? z.ZodType<Buffer> : TColumn['_']['dataType'] extends 'array' ? z.ZodArray<GetZodPrimitiveType<Assume<TColumn['_']['data'], any[]>[number], '', TCoerce>> : TColumn['_']['data'] extends Record<string, any> ? TColumn['_']['columnType'] extends 'PgJson' | 'PgJsonb' | 'MySqlJson' | 'SingleStoreJson' | 'SQLiteTextJson' | 'SQLiteBlobJson' ? z.ZodType<TColumn['_']['data'], TColumn['_']['data']> : z.ZodObject<{
12
- [K in keyof TColumn['_']['data']]: GetZodPrimitiveType<TColumn['_']['data'][K], '', TCoerce>;
13
- }, {
14
- out: {};
15
- in: {};
16
- }> : TColumn['_']['dataType'] extends 'json' ? z.ZodType<Json> : GetZodPrimitiveType<TColumn['_']['data'], TColumn['_']['columnType'], TCoerce>;
17
- type CanCoerce<TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined, TTo extends 'bigint' | 'boolean' | 'date' | 'number' | 'string'> = TCoerce extends true ? true : TCoerce extends Record<string, any> ? TCoerce[TTo] extends true ? true : false : false;
18
- type GetZodPrimitiveType<TData, TColumnType, TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined> = TColumnType extends 'MySqlTinyInt' | 'SingleStoreTinyInt' | 'PgSmallInt' | 'PgSmallSerial' | 'MySqlSmallInt' | 'MySqlMediumInt' | 'SingleStoreSmallInt' | 'SingleStoreMediumInt' | 'PgInteger' | 'PgSerial' | 'MySqlInt' | 'SingleStoreInt' | 'PgBigInt53' | 'PgBigSerial53' | 'MySqlBigInt53' | 'MySqlSerial' | 'SingleStoreBigInt53' | 'SingleStoreSerial' | 'SQLiteInteger' | 'MySqlYear' | 'SingleStoreYear' ? CanCoerce<TCoerce, 'number'> extends true ? z.coerce.ZodCoercedNumber : z.ZodInt : TData extends number ? CanCoerce<TCoerce, 'number'> extends true ? z.coerce.ZodCoercedNumber : z.ZodNumber : TData extends bigint ? CanCoerce<TCoerce, 'bigint'> extends true ? z.coerce.ZodCoercedBigInt : z.ZodBigInt : TData extends boolean ? CanCoerce<TCoerce, 'boolean'> extends true ? z.coerce.ZodCoercedBoolean : z.ZodBoolean : TData extends string ? CanCoerce<TCoerce, 'string'> extends true ? z.coerce.ZodCoercedString : z.ZodString : z.ZodType;
3
+ import type { bigintStringModeSchema } from './column.js';
4
+ import type { CoerceOptions } from './schema.types.js';
5
+ import type { Json } from './utils.js';
6
+ export type GetZodType<TColumn extends Column<any>, TCoerce extends CoerceOptions, TType extends ColumnTypeData = ExtractColumnTypeData<TColumn['_']['dataType']>, TCanCoerce extends boolean = CanCoerce<TCoerce, ColumnTypeDataToCoerceKey<TType>>> = TType['type'] extends 'array' ? TType['constraint'] extends 'geometry' | 'point' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber], null> : TType['constraint'] extends 'line' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null> : TType['constraint'] extends 'vector' | 'halfvector' ? z.ZodArray<z.ZodNumber> : TType['constraint'] extends 'int64vector' ? z.ZodArray<z.ZodBigInt> : TType['constraint'] extends 'basecolumn' ? z.ZodArray<GetZodType<Assume<TColumn['_'], {
7
+ baseColumn: Column<any>;
8
+ }>['baseColumn'], TCoerce>> : z.ZodArray<z.ZodAny> : TType['type'] extends 'object' ? TType['constraint'] extends 'date' ? CanCoerce<TCoerce, 'date'> extends true ? z.coerce.ZodCoercedDate : z.ZodDate : TType['constraint'] extends 'buffer' ? z.ZodType<Buffer> : TType['constraint'] extends 'point' | 'geometry' ? z.ZodObject<{
9
+ x: z.ZodNumber;
10
+ y: z.ZodNumber;
11
+ }, z.core.$strip> : TType['constraint'] extends 'line' ? z.ZodObject<{
12
+ a: z.ZodNumber;
13
+ b: z.ZodNumber;
14
+ c: z.ZodNumber;
15
+ }, z.core.$strip> : TType['constraint'] extends 'json' ? TColumn['_']['data'] extends Record<string, any> ? z.ZodType<TColumn['_']['data'], z.core.$strip> : z.ZodType<Json> : z.ZodObject<{}, z.core.$loose> : TType['type'] extends 'custom' ? z.ZodType : TType['type'] extends 'number' ? TCanCoerce extends true ? z.coerce.ZodCoercedNumber : (TType['constraint'] extends 'int8' | 'int16' | 'int24' | 'int32' | 'int53' | 'uint8' | 'uint16' | 'uint24' | 'uint32' | 'uint53' | 'year' ? z.ZodInt : z.ZodNumber) : TType['type'] extends 'bigint' ? TCanCoerce extends true ? z.coerce.ZodCoercedBigInt : z.ZodBigInt : TType['type'] extends 'boolean' ? TCanCoerce extends true ? z.coerce.ZodCoercedBoolean : z.ZodBoolean : TType['type'] extends 'string' ? TType['constraint'] extends 'uuid' ? z.ZodUUID : TCanCoerce extends true ? z.coerce.ZodCoercedString : TType['constraint'] extends 'enum' ? z.ZodEnum<{
16
+ [K in Assume<TColumn['_']['enumValues'], string[]>[number]]: K;
17
+ }> : TType['constraint'] extends 'int64' ? typeof bigintStringModeSchema : z.ZodString : z.ZodType;
18
+ type ColumnTypeDataToCoerceKey<TType extends ColumnTypeData> = TType['type'] extends 'bigint' | 'boolean' | 'number' | 'string' ? TType['type'] : TType['type'] extends 'object' ? TType['constraint'] extends 'date' ? TType['constraint'] : 'none' : 'none';
19
+ type CanCoerce<TCoerce extends CoerceOptions, TTo extends 'bigint' | 'boolean' | 'date' | 'number' | 'string' | 'none'> = TCoerce extends true ? true : TCoerce extends Record<string, any> ? TCoerce[TTo] extends true ? true : false : false;
19
20
  type HandleSelectColumn<TSchema extends z.ZodType, TColumn extends Column> = TColumn['_']['notNull'] extends true ? TSchema : z.ZodNullable<TSchema>;
20
21
  type HandleInsertColumn<TSchema extends z.ZodType, TColumn extends Column> = TColumn['_']['notNull'] extends true ? TColumn['_']['hasDefault'] extends true ? z.ZodOptional<TSchema> : TSchema : z.ZodOptional<z.ZodNullable<TSchema>>;
21
22
  type HandleUpdateColumn<TSchema extends z.ZodType, TColumn extends Column> = TColumn['_']['notNull'] extends true ? z.ZodOptional<TSchema> : z.ZodOptional<z.ZodNullable<TSchema>>;
22
- export type HandleColumn<TType extends 'select' | 'insert' | 'update', TColumn extends Column, TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined> = TType extends 'select' ? HandleSelectColumn<GetZodType<TColumn, TCoerce>, TColumn> : TType extends 'insert' ? HandleInsertColumn<GetZodType<TColumn, TCoerce>, TColumn> : TType extends 'update' ? HandleUpdateColumn<GetZodType<TColumn, TCoerce>, TColumn> : GetZodType<TColumn, TCoerce>;
23
+ export type HandleColumn<TType extends 'select' | 'insert' | 'update', TColumn extends Column, TCoerce extends CoerceOptions> = TType extends 'select' ? HandleSelectColumn<GetZodType<TColumn, TCoerce>, TColumn> : TType extends 'insert' ? HandleInsertColumn<GetZodType<TColumn, TCoerce>, TColumn> : TType extends 'update' ? HandleUpdateColumn<GetZodType<TColumn, TCoerce>, TColumn> : GetZodType<TColumn, TCoerce>;
23
24
  export {};