orchid-orm-schema-to-zod 0.5.7 → 0.6.0

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ParseColumn, EncodeColumn, AsTypeArg, ColumnTypeBase, ErrorMessage, NullableColumn, StringTypeData, ColumnSchemaGetterTableClass, ErrorMessages, ColumnSchemaGetterColumns, Code } from 'orchid-core';
2
- import { EnumColumn, ArrayColumnValue, DateBaseColumn, ColumnType, OperatorsJson, ColumnData, ArrayColumn } from 'pqb';
1
+ import { ParseColumn, EncodeColumn, AsTypeArg, ColumnTypeBase, NullableColumn, ColumnSchemaGetterTableClass, ErrorMessages, ColumnSchemaGetterColumns, Code, ErrorMessage, StringTypeData } from 'orchid-core';
2
+ import { EnumColumn, ArrayColumnValue, DateBaseColumn, ColumnType, OperatorsJson, ColumnData, ArrayColumn, SmallIntColumn, IntegerColumn, RealColumn, SmallSerialColumn, SerialColumn, BigIntColumn, DecimalColumn, DoublePrecisionColumn, BigSerialColumn, MoneyColumn, VarCharColumn, CharColumn, TextColumn, StringColumn, CitextColumn, DateColumn, TimestampColumn, TimestampTZColumn } from 'pqb';
3
3
  import { ZodTypeAny, ZodEnum, ZodNullable, ZodUnknown, ZodBoolean, ZodType, ZodNever, ZodString, ZodNumber, ZodDate, ZodObject, ZodOptional, ZodArray } from 'zod';
4
4
 
5
5
  type ParseDateToNumber = ParseColumn<DateBaseColumn<ZodSchemaConfig>, ZodNumber, number>;
@@ -11,17 +11,127 @@ declare class ZodJSONColumn<ZodSchema extends ZodTypeAny> extends ColumnType<Zod
11
11
  constructor(schema: ZodSchema);
12
12
  toCode(t: string): Code;
13
13
  }
14
- type ArrayMethods<Value> = {
14
+ interface ArrayMethods<Value> {
15
15
  min<T extends ColumnTypeBase>(this: T, value: Value, params?: ErrorMessage): T;
16
16
  max<T extends ColumnTypeBase>(this: T, value: Value, params?: ErrorMessage): T;
17
17
  length<T extends ColumnTypeBase>(this: T, value: Value, params?: ErrorMessage): T;
18
18
  nonEmpty<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
19
- };
19
+ }
20
20
  interface ZodArrayColumn<Item extends ArrayColumnValue> extends ArrayColumn<ZodSchemaConfig, Item, ZodArray<Item['inputSchema']>, ZodArray<Item['outputSchema']>, ZodArray<Item['querySchema']>>, ArrayMethods<number> {
21
21
  }
22
22
  declare class ZodArrayColumn<Item extends ArrayColumnValue> extends ArrayColumn<ZodSchemaConfig, Item, ZodArray<Item['inputSchema']>, ZodArray<Item['outputSchema']>, ZodArray<Item['querySchema']>> {
23
23
  constructor(item: Item);
24
24
  }
25
+ interface NumberMethods {
26
+ lt<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
27
+ lte<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
28
+ max<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
29
+ gt<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
30
+ gte<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
31
+ min<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
32
+ positive<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
33
+ nonNegative<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
34
+ negative<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
35
+ nonPositive<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
36
+ step<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
37
+ int<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
38
+ finite<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
39
+ safe<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
40
+ }
41
+ interface SmallIntColumnZod extends SmallIntColumn<ZodSchemaConfig>, NumberMethods {
42
+ }
43
+ declare class SmallIntColumnZod extends SmallIntColumn<ZodSchemaConfig> {
44
+ }
45
+ interface IntegerColumnZod extends IntegerColumn<ZodSchemaConfig>, NumberMethods {
46
+ }
47
+ declare class IntegerColumnZod extends IntegerColumn<ZodSchemaConfig> {
48
+ }
49
+ interface RealColumnZod extends RealColumn<ZodSchemaConfig>, NumberMethods {
50
+ }
51
+ declare class RealColumnZod extends RealColumn<ZodSchemaConfig> {
52
+ }
53
+ interface SmallSerialColumnZod extends SmallSerialColumn<ZodSchemaConfig>, NumberMethods {
54
+ }
55
+ declare class SmallSerialColumnZod extends SmallSerialColumn<ZodSchemaConfig> {
56
+ }
57
+ interface SerialColumnZod extends SerialColumn<ZodSchemaConfig>, NumberMethods {
58
+ }
59
+ declare class SerialColumnZod extends SerialColumn<ZodSchemaConfig> {
60
+ }
61
+ interface StringMethods extends ArrayMethods<number> {
62
+ email<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
63
+ url<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
64
+ emoji<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
65
+ uuid<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
66
+ cuid<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
67
+ cuid2<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
68
+ ulid<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
69
+ regex<T extends ColumnTypeBase>(this: T, value: RegExp, params?: ErrorMessage): T;
70
+ includes<T extends ColumnTypeBase, Value extends string>(this: T, value: Value, params?: ErrorMessage): T;
71
+ startsWith<T extends ColumnTypeBase, Value extends string>(this: T, value: Value, params?: ErrorMessage): T;
72
+ endsWith<T extends ColumnTypeBase, Value extends string>(this: T, value: Value, params?: ErrorMessage): T;
73
+ datetime<T extends ColumnTypeBase>(this: T, params?: StringTypeData['datetime'] & Exclude<ErrorMessage, string>): T;
74
+ ip<T extends ColumnTypeBase>(this: T, params?: StringTypeData['ip'] & Exclude<ErrorMessage, string>): T;
75
+ trim<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
76
+ toLowerCase<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
77
+ toUpperCase<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
78
+ }
79
+ interface BigIntColumnZod extends BigIntColumn<ZodSchemaConfig>, StringMethods {
80
+ }
81
+ declare class BigIntColumnZod extends BigIntColumn<ZodSchemaConfig> {
82
+ }
83
+ interface DecimalColumnZod extends DecimalColumn<ZodSchemaConfig>, StringMethods {
84
+ }
85
+ declare class DecimalColumnZod extends DecimalColumn<ZodSchemaConfig> {
86
+ }
87
+ interface DoublePrecisionColumnZod extends DoublePrecisionColumn<ZodSchemaConfig>, StringMethods {
88
+ }
89
+ declare class DoublePrecisionColumnZod extends DoublePrecisionColumn<ZodSchemaConfig> {
90
+ }
91
+ interface BigSerialColumnZod extends BigSerialColumn<ZodSchemaConfig>, StringMethods {
92
+ }
93
+ declare class BigSerialColumnZod extends BigSerialColumn<ZodSchemaConfig> {
94
+ }
95
+ interface MoneyColumnZod extends MoneyColumn<ZodSchemaConfig>, StringMethods {
96
+ }
97
+ declare class MoneyColumnZod extends MoneyColumn<ZodSchemaConfig> {
98
+ }
99
+ interface VarCharColumnZod extends VarCharColumn<ZodSchemaConfig>, StringMethods {
100
+ }
101
+ declare class VarCharColumnZod extends VarCharColumn<ZodSchemaConfig> {
102
+ }
103
+ interface CharColumnZod extends CharColumn<ZodSchemaConfig>, StringMethods {
104
+ }
105
+ declare class CharColumnZod extends CharColumn<ZodSchemaConfig> {
106
+ }
107
+ interface TextColumnZod extends TextColumn<ZodSchemaConfig>, StringMethods {
108
+ }
109
+ declare class TextColumnZod extends TextColumn<ZodSchemaConfig> {
110
+ }
111
+ interface StringColumnZod extends StringColumn<ZodSchemaConfig>, StringMethods {
112
+ }
113
+ declare class StringColumnZod extends StringColumn<ZodSchemaConfig> {
114
+ }
115
+ interface CitextColumnZod extends CitextColumn<ZodSchemaConfig>, StringMethods {
116
+ }
117
+ declare class CitextColumnZod extends CitextColumn<ZodSchemaConfig> {
118
+ }
119
+ interface DateMethods {
120
+ min<T extends ColumnTypeBase>(this: T, value: Date, params?: ErrorMessage): T;
121
+ max<T extends ColumnTypeBase>(this: T, value: Date, params?: ErrorMessage): T;
122
+ }
123
+ interface DateColumnZod extends DateColumn<ZodSchemaConfig>, DateMethods {
124
+ }
125
+ declare class DateColumnZod extends DateColumn<ZodSchemaConfig> {
126
+ }
127
+ interface TimestampNoTzColumnZod extends TimestampColumn<ZodSchemaConfig>, DateMethods {
128
+ }
129
+ declare class TimestampNoTzColumnZod extends TimestampColumn<ZodSchemaConfig> {
130
+ }
131
+ interface TimestampColumnZod extends TimestampTZColumn<ZodSchemaConfig>, DateMethods {
132
+ }
133
+ declare class TimestampColumnZod extends TimestampTZColumn<ZodSchemaConfig> {
134
+ }
25
135
  type ZodSchemaConfig = {
26
136
  type: ZodTypeAny;
27
137
  parse<T extends {
@@ -32,21 +142,11 @@ type ZodSchemaConfig = {
32
142
  }, InputSchema extends ZodTypeAny, Input = InputSchema['_output']>(this: T, _schema: InputSchema, fn: (input: Input) => unknown): EncodeColumn<T, InputSchema, Input>;
33
143
  asType<T, Types extends AsTypeArg<ZodTypeAny>, TypeSchema extends ZodTypeAny = Types extends {
34
144
  type: ZodTypeAny;
35
- } ? Types['type'] : never, Type = TypeSchema['_output']>(this: T, types: Types): Omit<T, 'type' | 'inputType' | 'inputSchema' | 'outputType' | 'outputSchema' | 'queryType' | 'querySchema'> & {
36
- type: Type;
37
- inputType: Types['input'] extends ZodTypeAny ? Types['input']['_output'] : Type;
38
- inputSchema: Types['input'] extends ZodTypeAny ? Types['input'] : TypeSchema;
39
- outputType: Types['output'] extends ZodTypeAny ? Types['output']['_output'] : Type;
40
- outputSchema: Types['output'] extends ZodTypeAny ? Types['output'] : TypeSchema;
41
- queryType: Types['query'] extends ZodTypeAny ? Types['query']['_output'] : Type;
42
- querySchema: Types['query'] extends ZodTypeAny ? Types['query'] : TypeSchema;
145
+ } ? Types['type'] : never, Type = TypeSchema['_output']>(this: T, types: Types): {
146
+ [K in keyof T]: K extends 'type' ? Type : K extends 'inputType' ? Types['input'] extends ZodTypeAny ? Types['input']['_output'] : Type : K extends 'inputSchema' ? Types['input'] extends ZodTypeAny ? Types['input'] : TypeSchema : K extends 'outputType' ? Types['output'] extends ZodTypeAny ? Types['output']['_output'] : Type : K extends 'outputSchema' ? Types['output'] extends ZodTypeAny ? Types['output'] : TypeSchema : K extends 'queryType' ? Types['query'] extends ZodTypeAny ? Types['query']['_output'] : Type : K extends 'querySchema' ? Types['query'] extends ZodTypeAny ? Types['query'] : TypeSchema : T[K];
43
147
  };
44
148
  dateAsNumber(): ParseDateToNumber;
45
149
  dateAsDate(): ParseDateToDate;
46
- dateMethods: {
47
- min<T extends ColumnTypeBase>(this: T, value: Date, params?: ErrorMessage): T;
48
- max<T extends ColumnTypeBase>(this: T, value: Date, params?: ErrorMessage): T;
49
- };
50
150
  enum<U extends string, T extends [U, ...U[]]>(dataType: string, type: T): EnumColumn<ZodSchemaConfig, ZodEnum<T>, U, T>;
51
151
  array<Item extends ArrayColumnValue>(item: Item): ZodArrayColumn<Item>;
52
152
  nullable<T extends ColumnTypeBase>(this: T): NullableColumn<T, ZodNullable<T['inputSchema']>, ZodNullable<T['outputSchema']>, ZodNullable<T['querySchema']>>;
@@ -55,45 +155,11 @@ type ZodSchemaConfig = {
55
155
  buffer: ZodType<Buffer>;
56
156
  unknown: ZodUnknown;
57
157
  never: ZodNever;
58
- string: ZodString;
158
+ stringSchema: ZodString;
59
159
  stringMin(max: number): ZodString;
60
160
  stringMax(max: number): ZodString;
61
161
  stringMinMax(min: number, max: number): ZodString;
62
- stringMethods: ArrayMethods<number> & {
63
- email<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
64
- url<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
65
- emoji<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
66
- uuid<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
67
- cuid<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
68
- cuid2<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
69
- ulid<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
70
- regex<T extends ColumnTypeBase>(this: T, value: RegExp, params?: ErrorMessage): T;
71
- includes<T extends ColumnTypeBase, Value extends string>(this: T, value: Value, params?: ErrorMessage): T;
72
- startsWith<T extends ColumnTypeBase, Value extends string>(this: T, value: Value, params?: ErrorMessage): T;
73
- endsWith<T extends ColumnTypeBase, Value extends string>(this: T, value: Value, params?: ErrorMessage): T;
74
- datetime<T extends ColumnTypeBase>(this: T, params?: StringTypeData['datetime'] & Exclude<ErrorMessage, string>): T;
75
- ip<T extends ColumnTypeBase>(this: T, params?: StringTypeData['ip'] & Exclude<ErrorMessage, string>): T;
76
- trim<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
77
- toLowerCase<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
78
- toUpperCase<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
79
- };
80
162
  number: ZodNumber;
81
- numberMethods: {
82
- lt<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
83
- lte<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
84
- max<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
85
- gt<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
86
- gte<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
87
- min<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
88
- positive<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
89
- nonNegative<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
90
- negative<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
91
- nonPositive<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
92
- step<T extends ColumnTypeBase>(this: T, value: number, params?: ErrorMessage): T;
93
- int<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
94
- finite<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
95
- safe<T extends ColumnTypeBase>(this: T, params?: ErrorMessage): T;
96
- };
97
163
  int: ZodNumber;
98
164
  stringNumberDate: ZodDate;
99
165
  timeInterval: ZodObject<{
@@ -112,6 +178,24 @@ type ZodSchemaConfig = {
112
178
  updateSchema<T extends ColumnSchemaGetterTableClass>(this: T): UpdateSchema<T>;
113
179
  pkeySchema<T extends ColumnSchemaGetterTableClass>(this: T): PkeySchema<T>;
114
180
  errors<T extends ColumnTypeBase>(this: T, errors: ErrorMessages): T;
181
+ smallint(): SmallIntColumnZod;
182
+ integer(): IntegerColumnZod;
183
+ real(): RealColumnZod;
184
+ smallSerial(): SmallSerialColumnZod;
185
+ serial(): SerialColumnZod;
186
+ bigint(): BigIntColumnZod;
187
+ decimal(precision?: number, scale?: number): DecimalColumnZod;
188
+ doublePrecision(): DoublePrecisionColumnZod;
189
+ bigSerial(): BigSerialColumnZod;
190
+ money(): MoneyColumnZod;
191
+ varchar(limit?: number): VarCharColumnZod;
192
+ char(limit?: number): CharColumnZod;
193
+ text(min: number, max: number): TextColumnZod;
194
+ string(limit?: number): StringColumnZod;
195
+ citext(min: number, max: number): CitextColumnZod;
196
+ date(): DateColumnZod;
197
+ timestampNoTZ(precision?: number): TimestampNoTzColumnZod;
198
+ timestamp(precision?: number): TimestampColumnZod;
115
199
  };
116
200
  declare const zodSchemaConfig: ZodSchemaConfig;
117
201
  type MapSchema<T extends ColumnSchemaGetterTableClass, Key extends 'inputSchema' | 'outputSchema' | 'querySchema'> = ZodObject<{
package/dist/index.js CHANGED
@@ -73,6 +73,176 @@ class ZodArrayColumn extends pqb.ArrayColumn {
73
73
  }
74
74
  }
75
75
  Object.assign(ZodArrayColumn.prototype, arrayMethods);
76
+ const numberMethods = {
77
+ // Require a value to be lower than a given number
78
+ lt(value, params) {
79
+ return applyMethod(this, "lt", value, params);
80
+ },
81
+ // Require a value to be lower than or equal to a given number (the same as `max`)
82
+ lte(value, params) {
83
+ return applyMethod(this, "lte", value, params);
84
+ },
85
+ // Require a value to be lower than or equal to a given number
86
+ max(value, params) {
87
+ return applyMethod(this, "lte", value, params);
88
+ },
89
+ // Require a value to be greater than a given number
90
+ gt(value, params) {
91
+ return applyMethod(this, "gt", value, params);
92
+ },
93
+ // Require a value to be greater than or equal to a given number (the same as `min`)
94
+ gte(value, params) {
95
+ return applyMethod(this, "gte", value, params);
96
+ },
97
+ // Require a value to be greater than or equal to a given number
98
+ min(value, params) {
99
+ return applyMethod(this, "gte", value, params);
100
+ },
101
+ // Require a value to be greater than 0
102
+ positive(params) {
103
+ return applyMethod(this, "gt", 0, params);
104
+ },
105
+ // Require a value to be greater than or equal to 0
106
+ nonNegative(params) {
107
+ return applyMethod(this, "gte", 0, params);
108
+ },
109
+ // Require a value to be lower than 0
110
+ negative(params) {
111
+ return applyMethod(this, "lt", 0, params);
112
+ },
113
+ // Require a value to be lower than or equal to 0
114
+ nonPositive(params) {
115
+ return applyMethod(this, "lte", 0, params);
116
+ },
117
+ // Require a value to be a multiple of a given number
118
+ step(value, params) {
119
+ return applyMethod(this, "step", value, params);
120
+ },
121
+ // Require a value to be an integer
122
+ int(params) {
123
+ return applySimpleMethod(this, "int", params);
124
+ },
125
+ // Exclude `Infinity` from being a valid value
126
+ finite(params) {
127
+ return applySimpleMethod(this, "finite", params);
128
+ },
129
+ // Require the value to be less than or equal to Number.MAX_SAFE_INTEGER
130
+ safe(params) {
131
+ return applySimpleMethod(this, "safe", params);
132
+ }
133
+ };
134
+ class SmallIntColumnZod extends pqb.SmallIntColumn {
135
+ }
136
+ Object.assign(SmallIntColumnZod.prototype, numberMethods);
137
+ class IntegerColumnZod extends pqb.IntegerColumn {
138
+ }
139
+ Object.assign(IntegerColumnZod.prototype, numberMethods);
140
+ class RealColumnZod extends pqb.RealColumn {
141
+ }
142
+ Object.assign(RealColumnZod.prototype, numberMethods);
143
+ class SmallSerialColumnZod extends pqb.SmallSerialColumn {
144
+ }
145
+ Object.assign(SmallSerialColumnZod.prototype, numberMethods);
146
+ class SerialColumnZod extends pqb.SerialColumn {
147
+ }
148
+ Object.assign(SerialColumnZod.prototype, numberMethods);
149
+ const stringMethods = __spreadProps(__spreadValues({}, arrayMethods), {
150
+ email(params) {
151
+ return applySimpleMethod(this, "email", params);
152
+ },
153
+ url(params) {
154
+ return applySimpleMethod(this, "url", params);
155
+ },
156
+ emoji(params) {
157
+ return applySimpleMethod(this, "emoji", params);
158
+ },
159
+ uuid(params) {
160
+ return applySimpleMethod(this, "uuid", params);
161
+ },
162
+ cuid(params) {
163
+ return applySimpleMethod(this, "cuid", params);
164
+ },
165
+ cuid2(params) {
166
+ return applySimpleMethod(this, "cuid2", params);
167
+ },
168
+ ulid(params) {
169
+ return applySimpleMethod(this, "ulid", params);
170
+ },
171
+ regex(value, params) {
172
+ return applyMethod(this, "regex", value, params);
173
+ },
174
+ includes(value, params) {
175
+ return applyMethod(this, "includes", value, params);
176
+ },
177
+ startsWith(value, params) {
178
+ return applyMethod(this, "startsWith", value, params);
179
+ },
180
+ endsWith(value, params) {
181
+ return applyMethod(this, "endsWith", value, params);
182
+ },
183
+ datetime(params = {}) {
184
+ return applyMethod(this, "datetime", params, params);
185
+ },
186
+ ip(params = {}) {
187
+ return applyMethod(this, "ip", params, params);
188
+ },
189
+ trim(params) {
190
+ return applySimpleMethod(this, "trim", params);
191
+ },
192
+ toLowerCase(params) {
193
+ return applySimpleMethod(this, "toLowerCase", params);
194
+ },
195
+ toUpperCase(params) {
196
+ return applySimpleMethod(this, "toUpperCase", params);
197
+ }
198
+ });
199
+ class BigIntColumnZod extends pqb.BigIntColumn {
200
+ }
201
+ Object.assign(BigIntColumnZod.prototype, stringMethods);
202
+ class DecimalColumnZod extends pqb.DecimalColumn {
203
+ }
204
+ Object.assign(DecimalColumnZod.prototype, stringMethods);
205
+ class DoublePrecisionColumnZod extends pqb.DoublePrecisionColumn {
206
+ }
207
+ Object.assign(DoublePrecisionColumnZod.prototype, stringMethods);
208
+ class BigSerialColumnZod extends pqb.BigSerialColumn {
209
+ }
210
+ Object.assign(BigSerialColumnZod.prototype, stringMethods);
211
+ class MoneyColumnZod extends pqb.MoneyColumn {
212
+ }
213
+ Object.assign(MoneyColumnZod.prototype, stringMethods);
214
+ class VarCharColumnZod extends pqb.VarCharColumn {
215
+ }
216
+ Object.assign(VarCharColumnZod.prototype, stringMethods);
217
+ class CharColumnZod extends pqb.CharColumn {
218
+ }
219
+ Object.assign(CharColumnZod.prototype, stringMethods);
220
+ class TextColumnZod extends pqb.TextColumn {
221
+ }
222
+ Object.assign(TextColumnZod.prototype, stringMethods);
223
+ class StringColumnZod extends pqb.StringColumn {
224
+ }
225
+ Object.assign(StringColumnZod.prototype, stringMethods);
226
+ class CitextColumnZod extends pqb.CitextColumn {
227
+ }
228
+ Object.assign(CitextColumnZod.prototype, stringMethods);
229
+ const dateMethods = {
230
+ min(value, params) {
231
+ return applyMethod(this, "min", value, params);
232
+ },
233
+ max(value, params) {
234
+ return applyMethod(this, "max", value, params);
235
+ }
236
+ };
237
+ class DateColumnZod extends pqb.DateColumn {
238
+ }
239
+ Object.assign(DateColumnZod.prototype, dateMethods);
240
+ class TimestampNoTzColumnZod extends pqb.TimestampColumn {
241
+ }
242
+ Object.assign(TimestampNoTzColumnZod.prototype, dateMethods);
243
+ class TimestampColumnZod extends pqb.TimestampTZColumn {
244
+ }
245
+ Object.assign(TimestampColumnZod.prototype, dateMethods);
76
246
  const parseDateToNumber = (value) => value ? Date.parse(value) : value;
77
247
  const parseDateToDate = (value) => value ? new Date(value) : value;
78
248
  const zodSchemaConfig = {
@@ -105,14 +275,6 @@ const zodSchemaConfig = {
105
275
  parseDateToDate
106
276
  );
107
277
  },
108
- dateMethods: {
109
- min(value, params) {
110
- return applyMethod(this, "min", value, params);
111
- },
112
- max(value, params) {
113
- return applyMethod(this, "max", value, params);
114
- }
115
- },
116
278
  enum(dataType, type) {
117
279
  return new pqb.EnumColumn(zodSchemaConfig, dataType, type, zod.z.enum(type));
118
280
  },
@@ -134,7 +296,7 @@ const zodSchemaConfig = {
134
296
  buffer: zod.z.instanceof(Buffer),
135
297
  unknown: zod.z.unknown(),
136
298
  never: zod.z.never(),
137
- string: zod.z.string(),
299
+ stringSchema: zod.z.string(),
138
300
  stringMin(min) {
139
301
  return zod.z.string().min(min);
140
302
  },
@@ -144,116 +306,8 @@ const zodSchemaConfig = {
144
306
  stringMinMax(min, max) {
145
307
  return zod.z.string().min(min).max(max);
146
308
  },
147
- stringMethods: __spreadProps(__spreadValues({}, arrayMethods), {
148
- email(params) {
149
- return applySimpleMethod(this, "email", params);
150
- },
151
- url(params) {
152
- return applySimpleMethod(this, "url", params);
153
- },
154
- emoji(params) {
155
- return applySimpleMethod(this, "emoji", params);
156
- },
157
- uuid(params) {
158
- return applySimpleMethod(this, "uuid", params);
159
- },
160
- cuid(params) {
161
- return applySimpleMethod(this, "cuid", params);
162
- },
163
- cuid2(params) {
164
- return applySimpleMethod(this, "cuid2", params);
165
- },
166
- ulid(params) {
167
- return applySimpleMethod(this, "ulid", params);
168
- },
169
- regex(value, params) {
170
- return applyMethod(this, "regex", value, params);
171
- },
172
- includes(value, params) {
173
- return applyMethod(this, "includes", value, params);
174
- },
175
- startsWith(value, params) {
176
- return applyMethod(this, "startsWith", value, params);
177
- },
178
- endsWith(value, params) {
179
- return applyMethod(this, "endsWith", value, params);
180
- },
181
- datetime(params = {}) {
182
- return applyMethod(this, "datetime", params, params);
183
- },
184
- ip(params = {}) {
185
- return applyMethod(this, "ip", params, params);
186
- },
187
- trim(params) {
188
- return applySimpleMethod(this, "trim", params);
189
- },
190
- toLowerCase(params) {
191
- return applySimpleMethod(this, "toLowerCase", params);
192
- },
193
- toUpperCase(params) {
194
- return applySimpleMethod(this, "toUpperCase", params);
195
- }
196
- }),
197
309
  number: zod.z.number(),
198
310
  int: zod.z.number().int(),
199
- numberMethods: {
200
- // Require a value to be lower than a given number
201
- lt(value, params) {
202
- return applyMethod(this, "lt", value, params);
203
- },
204
- // Require a value to be lower than or equal to a given number (the same as `max`)
205
- lte(value, params) {
206
- return applyMethod(this, "lte", value, params);
207
- },
208
- // Require a value to be lower than or equal to a given number
209
- max(value, params) {
210
- return applyMethod(this, "lte", value, params);
211
- },
212
- // Require a value to be greater than a given number
213
- gt(value, params) {
214
- return applyMethod(this, "gt", value, params);
215
- },
216
- // Require a value to be greater than or equal to a given number (the same as `min`)
217
- gte(value, params) {
218
- return applyMethod(this, "gte", value, params);
219
- },
220
- // Require a value to be greater than or equal to a given number
221
- min(value, params) {
222
- return applyMethod(this, "gte", value, params);
223
- },
224
- // Require a value to be greater than 0
225
- positive(params) {
226
- return applyMethod(this, "gt", 0, params);
227
- },
228
- // Require a value to be greater than or equal to 0
229
- nonNegative(params) {
230
- return applyMethod(this, "gte", 0, params);
231
- },
232
- // Require a value to be lower than 0
233
- negative(params) {
234
- return applyMethod(this, "lt", 0, params);
235
- },
236
- // Require a value to be lower than or equal to 0
237
- nonPositive(params) {
238
- return applyMethod(this, "lte", 0, params);
239
- },
240
- // Require a value to be a multiple of a given number
241
- step(value, params) {
242
- return applyMethod(this, "step", value, params);
243
- },
244
- // Require a value to be an integer
245
- int(params) {
246
- return applySimpleMethod(this, "int", params);
247
- },
248
- // Exclude `Infinity` from being a valid value
249
- finite(params) {
250
- return applySimpleMethod(this, "finite", params);
251
- },
252
- // Require the value to be less than or equal to Number.MAX_SAFE_INTEGER
253
- safe(params) {
254
- return applySimpleMethod(this, "safe", params);
255
- }
256
- },
257
311
  stringNumberDate: zod.z.coerce.date(),
258
312
  timeInterval: zod.z.object({
259
313
  years: zod.z.number().optional(),
@@ -366,7 +420,25 @@ const zodSchemaConfig = {
366
420
  };
367
421
  this.inputSchema._def.errorMap = this.outputSchema._def.errorMap = this.querySchema._def.errorMap = errorMap;
368
422
  return orchidCore.setColumnData(this, "errors", newErrors);
369
- }
423
+ },
424
+ smallint: () => new SmallIntColumnZod(zodSchemaConfig),
425
+ integer: () => new IntegerColumnZod(zodSchemaConfig),
426
+ real: () => new RealColumnZod(zodSchemaConfig),
427
+ smallSerial: () => new SmallSerialColumnZod(zodSchemaConfig),
428
+ serial: () => new SerialColumnZod(zodSchemaConfig),
429
+ bigint: () => new BigIntColumnZod(zodSchemaConfig),
430
+ decimal: (precision, scale) => new DecimalColumnZod(zodSchemaConfig, precision, scale),
431
+ doublePrecision: () => new DoublePrecisionColumnZod(zodSchemaConfig),
432
+ bigSerial: () => new BigSerialColumnZod(zodSchemaConfig),
433
+ money: () => new MoneyColumnZod(zodSchemaConfig),
434
+ varchar: (limit) => new VarCharColumnZod(zodSchemaConfig, limit),
435
+ char: (limit) => new CharColumnZod(zodSchemaConfig, limit),
436
+ text: (min, max) => new TextColumnZod(zodSchemaConfig, min, max),
437
+ string: (limit) => new StringColumnZod(zodSchemaConfig, limit),
438
+ citext: (min, max) => new CitextColumnZod(zodSchemaConfig, min, max),
439
+ date: () => new DateColumnZod(zodSchemaConfig),
440
+ timestampNoTZ: (precision) => new TimestampNoTzColumnZod(zodSchemaConfig, precision),
441
+ timestamp: (precision) => new TimestampColumnZod(zodSchemaConfig, precision)
370
442
  };
371
443
  function mapSchema(klass, schemaKey) {
372
444
  const shape = {};