cogsbox-shape 0.5.60 → 0.5.62
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/example/schema.d.ts +62 -0
- package/dist/example/user.d.ts +62 -0
- package/dist/example/user.js +1 -1
- package/dist/schema.d.ts +4 -0
- package/dist/schema.js +68 -6
- package/package.json +1 -1
package/dist/example/schema.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ declare const schemas: {
|
|
|
31
31
|
initialValue: string;
|
|
32
32
|
zodClientSchema: import("zod").ZodString;
|
|
33
33
|
zodValidationSchema: import("zod").ZodString;
|
|
34
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
35
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
34
36
|
} & {
|
|
35
37
|
transforms: {
|
|
36
38
|
toClient: (dbValue: string) => string;
|
|
@@ -65,6 +67,8 @@ declare const schemas: {
|
|
|
65
67
|
initialValue: string;
|
|
66
68
|
zodClientSchema: import("zod").ZodString;
|
|
67
69
|
zodValidationSchema: import("zod").ZodString;
|
|
70
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
71
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
68
72
|
} & {
|
|
69
73
|
transforms: {
|
|
70
74
|
toClient: (dbValue: string) => string;
|
|
@@ -99,6 +103,8 @@ declare const schemas: {
|
|
|
99
103
|
initialValue: string;
|
|
100
104
|
zodClientSchema: import("zod").ZodString;
|
|
101
105
|
zodValidationSchema: import("zod").ZodString;
|
|
106
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
107
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
102
108
|
} & {
|
|
103
109
|
transforms: {
|
|
104
110
|
toClient: (dbValue: string) => string;
|
|
@@ -125,6 +131,8 @@ declare const schemas: {
|
|
|
125
131
|
initialValue: string;
|
|
126
132
|
zodClientSchema: import("zod").ZodUnion<[import("zod").ZodNumber, import("zod").ZodNumber]>;
|
|
127
133
|
zodValidationSchema: import("zod").ZodString;
|
|
134
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
135
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
128
136
|
} & {
|
|
129
137
|
transforms: {
|
|
130
138
|
toClient: (dbValue: number) => number;
|
|
@@ -153,6 +161,8 @@ declare const schemas: {
|
|
|
153
161
|
initialValue: string;
|
|
154
162
|
zodClientSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
155
163
|
zodValidationSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
164
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
165
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
156
166
|
} & {
|
|
157
167
|
transforms: {
|
|
158
168
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -170,6 +180,8 @@ declare const schemas: {
|
|
|
170
180
|
initialValue: number;
|
|
171
181
|
zodClientSchema: import("zod").ZodBoolean;
|
|
172
182
|
zodValidationSchema: import("zod").ZodBoolean;
|
|
183
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
184
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
173
185
|
} & {
|
|
174
186
|
transforms: {
|
|
175
187
|
toClient: (dbValue: number) => boolean;
|
|
@@ -197,6 +209,8 @@ declare const schemas: {
|
|
|
197
209
|
initialValue: string;
|
|
198
210
|
zodClientSchema: import("zod").ZodUnion<[import("zod").ZodNumber, import("zod").ZodNumber]>;
|
|
199
211
|
zodValidationSchema: import("zod").ZodString;
|
|
212
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
213
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
200
214
|
} & {
|
|
201
215
|
transforms: {
|
|
202
216
|
toClient: (dbValue: number) => number;
|
|
@@ -225,6 +239,8 @@ declare const schemas: {
|
|
|
225
239
|
initialValue: string;
|
|
226
240
|
zodClientSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
227
241
|
zodValidationSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
242
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
243
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
228
244
|
} & {
|
|
229
245
|
transforms: {
|
|
230
246
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -242,6 +258,8 @@ declare const schemas: {
|
|
|
242
258
|
initialValue: number;
|
|
243
259
|
zodClientSchema: import("zod").ZodBoolean;
|
|
244
260
|
zodValidationSchema: import("zod").ZodBoolean;
|
|
261
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
262
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
245
263
|
} & {
|
|
246
264
|
transforms: {
|
|
247
265
|
toClient: (dbValue: number) => boolean;
|
|
@@ -269,6 +287,8 @@ declare const schemas: {
|
|
|
269
287
|
initialValue: string;
|
|
270
288
|
zodClientSchema: import("zod").ZodUnion<[import("zod").ZodNumber, import("zod").ZodNumber]>;
|
|
271
289
|
zodValidationSchema: import("zod").ZodString;
|
|
290
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
291
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
272
292
|
} & {
|
|
273
293
|
transforms: {
|
|
274
294
|
toClient: (dbValue: number) => number;
|
|
@@ -297,6 +317,8 @@ declare const schemas: {
|
|
|
297
317
|
initialValue: string;
|
|
298
318
|
zodClientSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
299
319
|
zodValidationSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
320
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
321
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
300
322
|
} & {
|
|
301
323
|
transforms: {
|
|
302
324
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -314,6 +336,8 @@ declare const schemas: {
|
|
|
314
336
|
initialValue: number;
|
|
315
337
|
zodClientSchema: import("zod").ZodBoolean;
|
|
316
338
|
zodValidationSchema: import("zod").ZodBoolean;
|
|
339
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
340
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
317
341
|
} & {
|
|
318
342
|
transforms: {
|
|
319
343
|
toClient: (dbValue: number) => boolean;
|
|
@@ -341,6 +365,8 @@ declare const schemas: {
|
|
|
341
365
|
initialValue: string;
|
|
342
366
|
zodClientSchema: import("zod").ZodUnion<[import("zod").ZodNumber, import("zod").ZodNumber]>;
|
|
343
367
|
zodValidationSchema: import("zod").ZodString;
|
|
368
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
369
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
344
370
|
} & {
|
|
345
371
|
transforms: {
|
|
346
372
|
toClient: (dbValue: number) => number;
|
|
@@ -369,6 +395,8 @@ declare const schemas: {
|
|
|
369
395
|
initialValue: string;
|
|
370
396
|
zodClientSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
371
397
|
zodValidationSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
398
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
399
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
372
400
|
} & {
|
|
373
401
|
transforms: {
|
|
374
402
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -386,6 +414,8 @@ declare const schemas: {
|
|
|
386
414
|
initialValue: number;
|
|
387
415
|
zodClientSchema: import("zod").ZodBoolean;
|
|
388
416
|
zodValidationSchema: import("zod").ZodBoolean;
|
|
417
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
418
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
389
419
|
} & {
|
|
390
420
|
transforms: {
|
|
391
421
|
toClient: (dbValue: number) => boolean;
|
|
@@ -521,6 +551,8 @@ declare const schemas: {
|
|
|
521
551
|
initialValue: string;
|
|
522
552
|
zodClientSchema: import("zod").ZodUnion<[import("zod").ZodNumber, import("zod").ZodNumber]>;
|
|
523
553
|
zodValidationSchema: import("zod").ZodString;
|
|
554
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
555
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
524
556
|
} & {
|
|
525
557
|
transforms: {
|
|
526
558
|
toClient: (dbValue: number) => number;
|
|
@@ -549,6 +581,8 @@ declare const schemas: {
|
|
|
549
581
|
initialValue: string;
|
|
550
582
|
zodClientSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
551
583
|
zodValidationSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
584
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
585
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
552
586
|
} & {
|
|
553
587
|
transforms: {
|
|
554
588
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -566,6 +600,8 @@ declare const schemas: {
|
|
|
566
600
|
initialValue: number;
|
|
567
601
|
zodClientSchema: import("zod").ZodBoolean;
|
|
568
602
|
zodValidationSchema: import("zod").ZodBoolean;
|
|
603
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
604
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
569
605
|
} & {
|
|
570
606
|
transforms: {
|
|
571
607
|
toClient: (dbValue: number) => boolean;
|
|
@@ -593,6 +629,8 @@ declare const schemas: {
|
|
|
593
629
|
initialValue: string;
|
|
594
630
|
zodClientSchema: import("zod").ZodUnion<[import("zod").ZodNumber, import("zod").ZodNumber]>;
|
|
595
631
|
zodValidationSchema: import("zod").ZodString;
|
|
632
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
633
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
596
634
|
} & {
|
|
597
635
|
transforms: {
|
|
598
636
|
toClient: (dbValue: number) => number;
|
|
@@ -621,6 +659,8 @@ declare const schemas: {
|
|
|
621
659
|
initialValue: string;
|
|
622
660
|
zodClientSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
623
661
|
zodValidationSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
662
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
663
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
624
664
|
} & {
|
|
625
665
|
transforms: {
|
|
626
666
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -638,6 +678,8 @@ declare const schemas: {
|
|
|
638
678
|
initialValue: number;
|
|
639
679
|
zodClientSchema: import("zod").ZodBoolean;
|
|
640
680
|
zodValidationSchema: import("zod").ZodBoolean;
|
|
681
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
682
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
641
683
|
} & {
|
|
642
684
|
transforms: {
|
|
643
685
|
toClient: (dbValue: number) => boolean;
|
|
@@ -665,6 +707,8 @@ declare const schemas: {
|
|
|
665
707
|
initialValue: string;
|
|
666
708
|
zodClientSchema: import("zod").ZodUnion<[import("zod").ZodNumber, import("zod").ZodNumber]>;
|
|
667
709
|
zodValidationSchema: import("zod").ZodString;
|
|
710
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
711
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
668
712
|
} & {
|
|
669
713
|
transforms: {
|
|
670
714
|
toClient: (dbValue: number) => number;
|
|
@@ -693,6 +737,8 @@ declare const schemas: {
|
|
|
693
737
|
initialValue: string;
|
|
694
738
|
zodClientSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
695
739
|
zodValidationSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
740
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
741
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
696
742
|
} & {
|
|
697
743
|
transforms: {
|
|
698
744
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -710,6 +756,8 @@ declare const schemas: {
|
|
|
710
756
|
initialValue: number;
|
|
711
757
|
zodClientSchema: import("zod").ZodBoolean;
|
|
712
758
|
zodValidationSchema: import("zod").ZodBoolean;
|
|
759
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
760
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
713
761
|
} & {
|
|
714
762
|
transforms: {
|
|
715
763
|
toClient: (dbValue: number) => boolean;
|
|
@@ -737,6 +785,8 @@ declare const schemas: {
|
|
|
737
785
|
initialValue: string;
|
|
738
786
|
zodClientSchema: import("zod").ZodUnion<[import("zod").ZodNumber, import("zod").ZodNumber]>;
|
|
739
787
|
zodValidationSchema: import("zod").ZodString;
|
|
788
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
789
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
740
790
|
} & {
|
|
741
791
|
transforms: {
|
|
742
792
|
toClient: (dbValue: number) => number;
|
|
@@ -765,6 +815,8 @@ declare const schemas: {
|
|
|
765
815
|
initialValue: string;
|
|
766
816
|
zodClientSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
767
817
|
zodValidationSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
818
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
819
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
768
820
|
} & {
|
|
769
821
|
transforms: {
|
|
770
822
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -782,6 +834,8 @@ declare const schemas: {
|
|
|
782
834
|
initialValue: number;
|
|
783
835
|
zodClientSchema: import("zod").ZodBoolean;
|
|
784
836
|
zodValidationSchema: import("zod").ZodBoolean;
|
|
837
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
838
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
785
839
|
} & {
|
|
786
840
|
transforms: {
|
|
787
841
|
toClient: (dbValue: number) => boolean;
|
|
@@ -871,6 +925,8 @@ declare const schemas: {
|
|
|
871
925
|
favourite: number;
|
|
872
926
|
userId?: any;
|
|
873
927
|
}>, "many">;
|
|
928
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
929
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
874
930
|
} & {
|
|
875
931
|
transforms: {
|
|
876
932
|
toClient: (dbValue: {
|
|
@@ -917,6 +973,8 @@ declare const schemas: {
|
|
|
917
973
|
initialValue: string;
|
|
918
974
|
zodClientSchema: import("zod").ZodUnion<[import("zod").ZodNumber, import("zod").ZodNumber]>;
|
|
919
975
|
zodValidationSchema: import("zod").ZodString;
|
|
976
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
977
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
920
978
|
} & {
|
|
921
979
|
transforms: {
|
|
922
980
|
toClient: (dbValue: number) => number;
|
|
@@ -945,6 +1003,8 @@ declare const schemas: {
|
|
|
945
1003
|
initialValue: string;
|
|
946
1004
|
zodClientSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
947
1005
|
zodValidationSchema: import("zod").ZodArray<import("zod").ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
1006
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
1007
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
948
1008
|
} & {
|
|
949
1009
|
transforms: {
|
|
950
1010
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -962,6 +1022,8 @@ declare const schemas: {
|
|
|
962
1022
|
initialValue: number;
|
|
963
1023
|
zodClientSchema: import("zod").ZodBoolean;
|
|
964
1024
|
zodValidationSchema: import("zod").ZodBoolean;
|
|
1025
|
+
clientTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
1026
|
+
validationTransform?: (schema: import("zod").ZodTypeAny) => import("zod").ZodTypeAny;
|
|
965
1027
|
} & {
|
|
966
1028
|
transforms: {
|
|
967
1029
|
toClient: (dbValue: number) => boolean;
|
package/dist/example/user.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare const petSchema: {
|
|
|
12
12
|
initialValue: string;
|
|
13
13
|
zodClientSchema: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
|
|
14
14
|
zodValidationSchema: z.ZodString;
|
|
15
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
16
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
15
17
|
} & {
|
|
16
18
|
transforms: {
|
|
17
19
|
toClient: (dbValue: number) => number;
|
|
@@ -40,6 +42,8 @@ export declare const petSchema: {
|
|
|
40
42
|
initialValue: string;
|
|
41
43
|
zodClientSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
42
44
|
zodValidationSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
45
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
46
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
43
47
|
} & {
|
|
44
48
|
transforms: {
|
|
45
49
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -57,6 +61,8 @@ export declare const petSchema: {
|
|
|
57
61
|
initialValue: number;
|
|
58
62
|
zodClientSchema: z.ZodBoolean;
|
|
59
63
|
zodValidationSchema: z.ZodBoolean;
|
|
64
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
65
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
60
66
|
} & {
|
|
61
67
|
transforms: {
|
|
62
68
|
toClient: (dbValue: number) => boolean;
|
|
@@ -97,6 +103,8 @@ export declare const userSchema: {
|
|
|
97
103
|
initialValue: string;
|
|
98
104
|
zodClientSchema: z.ZodString;
|
|
99
105
|
zodValidationSchema: z.ZodString;
|
|
106
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
107
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
100
108
|
} & {
|
|
101
109
|
transforms: {
|
|
102
110
|
toClient: (dbValue: string) => string;
|
|
@@ -131,6 +139,8 @@ export declare const userSchema: {
|
|
|
131
139
|
initialValue: string;
|
|
132
140
|
zodClientSchema: z.ZodString;
|
|
133
141
|
zodValidationSchema: z.ZodString;
|
|
142
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
143
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
134
144
|
} & {
|
|
135
145
|
transforms: {
|
|
136
146
|
toClient: (dbValue: string) => string;
|
|
@@ -165,6 +175,8 @@ export declare const userSchema: {
|
|
|
165
175
|
initialValue: string;
|
|
166
176
|
zodClientSchema: z.ZodString;
|
|
167
177
|
zodValidationSchema: z.ZodString;
|
|
178
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
179
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
168
180
|
} & {
|
|
169
181
|
transforms: {
|
|
170
182
|
toClient: (dbValue: string) => string;
|
|
@@ -191,6 +203,8 @@ export declare const userSchema: {
|
|
|
191
203
|
initialValue: string;
|
|
192
204
|
zodClientSchema: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
|
|
193
205
|
zodValidationSchema: z.ZodString;
|
|
206
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
207
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
194
208
|
} & {
|
|
195
209
|
transforms: {
|
|
196
210
|
toClient: (dbValue: number) => number;
|
|
@@ -219,6 +233,8 @@ export declare const userSchema: {
|
|
|
219
233
|
initialValue: string;
|
|
220
234
|
zodClientSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
221
235
|
zodValidationSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
236
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
237
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
222
238
|
} & {
|
|
223
239
|
transforms: {
|
|
224
240
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -236,6 +252,8 @@ export declare const userSchema: {
|
|
|
236
252
|
initialValue: number;
|
|
237
253
|
zodClientSchema: z.ZodBoolean;
|
|
238
254
|
zodValidationSchema: z.ZodBoolean;
|
|
255
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
256
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
239
257
|
} & {
|
|
240
258
|
transforms: {
|
|
241
259
|
toClient: (dbValue: number) => boolean;
|
|
@@ -263,6 +281,8 @@ export declare const userSchema: {
|
|
|
263
281
|
initialValue: string;
|
|
264
282
|
zodClientSchema: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
|
|
265
283
|
zodValidationSchema: z.ZodString;
|
|
284
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
285
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
266
286
|
} & {
|
|
267
287
|
transforms: {
|
|
268
288
|
toClient: (dbValue: number) => number;
|
|
@@ -291,6 +311,8 @@ export declare const userSchema: {
|
|
|
291
311
|
initialValue: string;
|
|
292
312
|
zodClientSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
293
313
|
zodValidationSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
314
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
315
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
294
316
|
} & {
|
|
295
317
|
transforms: {
|
|
296
318
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -308,6 +330,8 @@ export declare const userSchema: {
|
|
|
308
330
|
initialValue: number;
|
|
309
331
|
zodClientSchema: z.ZodBoolean;
|
|
310
332
|
zodValidationSchema: z.ZodBoolean;
|
|
333
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
334
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
311
335
|
} & {
|
|
312
336
|
transforms: {
|
|
313
337
|
toClient: (dbValue: number) => boolean;
|
|
@@ -335,6 +359,8 @@ export declare const userSchema: {
|
|
|
335
359
|
initialValue: string;
|
|
336
360
|
zodClientSchema: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
|
|
337
361
|
zodValidationSchema: z.ZodString;
|
|
362
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
363
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
338
364
|
} & {
|
|
339
365
|
transforms: {
|
|
340
366
|
toClient: (dbValue: number) => number;
|
|
@@ -363,6 +389,8 @@ export declare const userSchema: {
|
|
|
363
389
|
initialValue: string;
|
|
364
390
|
zodClientSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
365
391
|
zodValidationSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
392
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
393
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
366
394
|
} & {
|
|
367
395
|
transforms: {
|
|
368
396
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -380,6 +408,8 @@ export declare const userSchema: {
|
|
|
380
408
|
initialValue: number;
|
|
381
409
|
zodClientSchema: z.ZodBoolean;
|
|
382
410
|
zodValidationSchema: z.ZodBoolean;
|
|
411
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
412
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
383
413
|
} & {
|
|
384
414
|
transforms: {
|
|
385
415
|
toClient: (dbValue: number) => boolean;
|
|
@@ -407,6 +437,8 @@ export declare const userSchema: {
|
|
|
407
437
|
initialValue: string;
|
|
408
438
|
zodClientSchema: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
|
|
409
439
|
zodValidationSchema: z.ZodString;
|
|
440
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
441
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
410
442
|
} & {
|
|
411
443
|
transforms: {
|
|
412
444
|
toClient: (dbValue: number) => number;
|
|
@@ -435,6 +467,8 @@ export declare const userSchema: {
|
|
|
435
467
|
initialValue: string;
|
|
436
468
|
zodClientSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
437
469
|
zodValidationSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
470
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
471
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
438
472
|
} & {
|
|
439
473
|
transforms: {
|
|
440
474
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -452,6 +486,8 @@ export declare const userSchema: {
|
|
|
452
486
|
initialValue: number;
|
|
453
487
|
zodClientSchema: z.ZodBoolean;
|
|
454
488
|
zodValidationSchema: z.ZodBoolean;
|
|
489
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
490
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
455
491
|
} & {
|
|
456
492
|
transforms: {
|
|
457
493
|
toClient: (dbValue: number) => boolean;
|
|
@@ -587,6 +623,8 @@ export declare const userSchema: {
|
|
|
587
623
|
initialValue: string;
|
|
588
624
|
zodClientSchema: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
|
|
589
625
|
zodValidationSchema: z.ZodString;
|
|
626
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
627
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
590
628
|
} & {
|
|
591
629
|
transforms: {
|
|
592
630
|
toClient: (dbValue: number) => number;
|
|
@@ -615,6 +653,8 @@ export declare const userSchema: {
|
|
|
615
653
|
initialValue: string;
|
|
616
654
|
zodClientSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
617
655
|
zodValidationSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
656
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
657
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
618
658
|
} & {
|
|
619
659
|
transforms: {
|
|
620
660
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -632,6 +672,8 @@ export declare const userSchema: {
|
|
|
632
672
|
initialValue: number;
|
|
633
673
|
zodClientSchema: z.ZodBoolean;
|
|
634
674
|
zodValidationSchema: z.ZodBoolean;
|
|
675
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
676
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
635
677
|
} & {
|
|
636
678
|
transforms: {
|
|
637
679
|
toClient: (dbValue: number) => boolean;
|
|
@@ -659,6 +701,8 @@ export declare const userSchema: {
|
|
|
659
701
|
initialValue: string;
|
|
660
702
|
zodClientSchema: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
|
|
661
703
|
zodValidationSchema: z.ZodString;
|
|
704
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
705
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
662
706
|
} & {
|
|
663
707
|
transforms: {
|
|
664
708
|
toClient: (dbValue: number) => number;
|
|
@@ -687,6 +731,8 @@ export declare const userSchema: {
|
|
|
687
731
|
initialValue: string;
|
|
688
732
|
zodClientSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
689
733
|
zodValidationSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
734
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
735
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
690
736
|
} & {
|
|
691
737
|
transforms: {
|
|
692
738
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -704,6 +750,8 @@ export declare const userSchema: {
|
|
|
704
750
|
initialValue: number;
|
|
705
751
|
zodClientSchema: z.ZodBoolean;
|
|
706
752
|
zodValidationSchema: z.ZodBoolean;
|
|
753
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
754
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
707
755
|
} & {
|
|
708
756
|
transforms: {
|
|
709
757
|
toClient: (dbValue: number) => boolean;
|
|
@@ -731,6 +779,8 @@ export declare const userSchema: {
|
|
|
731
779
|
initialValue: string;
|
|
732
780
|
zodClientSchema: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
|
|
733
781
|
zodValidationSchema: z.ZodString;
|
|
782
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
783
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
734
784
|
} & {
|
|
735
785
|
transforms: {
|
|
736
786
|
toClient: (dbValue: number) => number;
|
|
@@ -759,6 +809,8 @@ export declare const userSchema: {
|
|
|
759
809
|
initialValue: string;
|
|
760
810
|
zodClientSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
761
811
|
zodValidationSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
812
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
813
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
762
814
|
} & {
|
|
763
815
|
transforms: {
|
|
764
816
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -776,6 +828,8 @@ export declare const userSchema: {
|
|
|
776
828
|
initialValue: number;
|
|
777
829
|
zodClientSchema: z.ZodBoolean;
|
|
778
830
|
zodValidationSchema: z.ZodBoolean;
|
|
831
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
832
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
779
833
|
} & {
|
|
780
834
|
transforms: {
|
|
781
835
|
toClient: (dbValue: number) => boolean;
|
|
@@ -803,6 +857,8 @@ export declare const userSchema: {
|
|
|
803
857
|
initialValue: string;
|
|
804
858
|
zodClientSchema: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
|
|
805
859
|
zodValidationSchema: z.ZodString;
|
|
860
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
861
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
806
862
|
} & {
|
|
807
863
|
transforms: {
|
|
808
864
|
toClient: (dbValue: number) => number;
|
|
@@ -831,6 +887,8 @@ export declare const userSchema: {
|
|
|
831
887
|
initialValue: string;
|
|
832
888
|
zodClientSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
833
889
|
zodValidationSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
|
|
890
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
891
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
834
892
|
} & {
|
|
835
893
|
transforms: {
|
|
836
894
|
toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
|
|
@@ -848,6 +906,8 @@ export declare const userSchema: {
|
|
|
848
906
|
initialValue: number;
|
|
849
907
|
zodClientSchema: z.ZodBoolean;
|
|
850
908
|
zodValidationSchema: z.ZodBoolean;
|
|
909
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
910
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
851
911
|
} & {
|
|
852
912
|
transforms: {
|
|
853
913
|
toClient: (dbValue: number) => boolean;
|
|
@@ -937,6 +997,8 @@ export declare const userSchema: {
|
|
|
937
997
|
favourite: number;
|
|
938
998
|
userId?: any;
|
|
939
999
|
}>, "many">;
|
|
1000
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
1001
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
940
1002
|
} & {
|
|
941
1003
|
transforms: {
|
|
942
1004
|
toClient: (dbValue: {
|
package/dist/example/user.js
CHANGED
package/dist/schema.d.ts
CHANGED
|
@@ -111,6 +111,8 @@ type BuilderConfig<T extends SQLType | RelationConfig<any>, TSql extends z.ZodTy
|
|
|
111
111
|
initialValue: TInitialValue;
|
|
112
112
|
zodClientSchema: TClient;
|
|
113
113
|
zodValidationSchema: TValidation;
|
|
114
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
115
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
114
116
|
};
|
|
115
117
|
export type Builder<TStage extends Stage, T extends SQLType | RelationConfig<any>, TSql extends z.ZodTypeAny, TNew extends z.ZodTypeAny, TInitialValue, TClient extends z.ZodTypeAny, TValidation extends z.ZodTypeAny> = {
|
|
116
118
|
config: {
|
|
@@ -160,6 +162,8 @@ declare function createBuilder<TStage extends "sql" | "relation" | "new" | "clie
|
|
|
160
162
|
clientZod: TClient;
|
|
161
163
|
validationZod: TValidation;
|
|
162
164
|
completedStages?: Set<string>;
|
|
165
|
+
clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
166
|
+
validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
|
|
163
167
|
}): Builder<TStage, T, TSql, TNew, TInitialValue, TClient, TValidation>;
|
|
164
168
|
export declare function hasMany<T extends Schema<any>>(config: {
|
|
165
169
|
fromKey: string;
|
package/dist/schema.js
CHANGED
|
@@ -129,7 +129,7 @@ export const shape = {
|
|
|
129
129
|
});
|
|
130
130
|
},
|
|
131
131
|
};
|
|
132
|
-
//
|
|
132
|
+
// PASTE THIS ENTIRE FUNCTION OVER YOUR EXISTING createBuilder
|
|
133
133
|
function createBuilder(config) {
|
|
134
134
|
const completedStages = config.completedStages || new Set([config.stage]);
|
|
135
135
|
const builderObject = {
|
|
@@ -141,8 +141,12 @@ function createBuilder(config) {
|
|
|
141
141
|
inferDefaultFromZod(config.clientZod, config.sqlConfig),
|
|
142
142
|
zodClientSchema: config.clientZod,
|
|
143
143
|
zodValidationSchema: config.validationZod,
|
|
144
|
+
clientTransform: config.clientTransform, // <-- FIX: Make sure transform is passed through
|
|
145
|
+
validationTransform: config.validationTransform, // <-- FIX: Make sure transform is passed through
|
|
144
146
|
},
|
|
145
|
-
initialState: (
|
|
147
|
+
initialState: (
|
|
148
|
+
// ... this initialState function remains unchanged ...
|
|
149
|
+
schemaOrDefault, defaultValue) => {
|
|
146
150
|
if (completedStages.has("new")) {
|
|
147
151
|
throw new Error("initialState() can only be called once in the chain");
|
|
148
152
|
}
|
|
@@ -185,11 +189,32 @@ function createBuilder(config) {
|
|
|
185
189
|
if (completedStages.has("validation")) {
|
|
186
190
|
throw new Error("client() must be called before validation()");
|
|
187
191
|
}
|
|
192
|
+
const newCompletedStages = new Set(completedStages);
|
|
193
|
+
newCompletedStages.add("client");
|
|
194
|
+
// ---- THIS IS THE MAIN FIX ----
|
|
195
|
+
if (config.stage === "relation") {
|
|
196
|
+
return createBuilder({
|
|
197
|
+
...config,
|
|
198
|
+
stage: "client",
|
|
199
|
+
completedStages: newCompletedStages,
|
|
200
|
+
// Store the transform function to be used later
|
|
201
|
+
clientTransform: (baseSchema) => {
|
|
202
|
+
if (isFunction(assert)) {
|
|
203
|
+
// We use `as any` here to resolve the complex generic type error.
|
|
204
|
+
// It's safe because we know the baseSchema will have the necessary Zod methods.
|
|
205
|
+
return assert({
|
|
206
|
+
sql: baseSchema,
|
|
207
|
+
initialState: config.newZod,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
return assert;
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
// This is the original logic for non-relation fields
|
|
188
215
|
const clientSchema = isFunction(assert)
|
|
189
216
|
? assert({ sql: config.sqlZod, initialState: config.newZod })
|
|
190
217
|
: assert;
|
|
191
|
-
const newCompletedStages = new Set(completedStages);
|
|
192
|
-
newCompletedStages.add("client");
|
|
193
218
|
return createBuilder({
|
|
194
219
|
...config,
|
|
195
220
|
stage: "client",
|
|
@@ -198,7 +223,9 @@ function createBuilder(config) {
|
|
|
198
223
|
completedStages: newCompletedStages,
|
|
199
224
|
});
|
|
200
225
|
},
|
|
201
|
-
validation: (
|
|
226
|
+
validation: (
|
|
227
|
+
// ... this validation function remains unchanged ...
|
|
228
|
+
assert) => {
|
|
202
229
|
if (completedStages.has("validation")) {
|
|
203
230
|
throw new Error("validation() can only be called once in the chain");
|
|
204
231
|
}
|
|
@@ -437,7 +464,7 @@ export function createSchema(schema) {
|
|
|
437
464
|
}
|
|
438
465
|
}
|
|
439
466
|
}
|
|
440
|
-
//
|
|
467
|
+
// In createSchema function, in PASS 2 where relations are processed:
|
|
441
468
|
for (const { key, definition } of deferredFields) {
|
|
442
469
|
let resolvedDefinition = definition;
|
|
443
470
|
// If it's a relation like hasMany, call the outer function to get the config object
|
|
@@ -456,6 +483,7 @@ export function createSchema(schema) {
|
|
|
456
483
|
}
|
|
457
484
|
else if (resolvedDefinition &&
|
|
458
485
|
["hasMany", "manyToMany", "hasOne", "belongsTo"].includes(resolvedDefinition.type)) {
|
|
486
|
+
// Handle legacy function-style relations
|
|
459
487
|
const relation = resolvedDefinition;
|
|
460
488
|
const childSchemaResult = createSchema(relation.schema);
|
|
461
489
|
if (relation.type === "hasMany" || relation.type === "manyToMany") {
|
|
@@ -474,6 +502,40 @@ export function createSchema(schema) {
|
|
|
474
502
|
defaultValues[key] = childSchemaResult.defaultValues;
|
|
475
503
|
}
|
|
476
504
|
}
|
|
505
|
+
else if (definition &&
|
|
506
|
+
definition.config &&
|
|
507
|
+
definition.config.sql &&
|
|
508
|
+
typeof definition.config.sql === "object" &&
|
|
509
|
+
["hasMany", "hasOne", "belongsTo", "manyToMany"].includes(definition.config.sql.type)) {
|
|
510
|
+
// This is a builder-style relation like `shape.hasMany().client()`
|
|
511
|
+
const config = definition.config;
|
|
512
|
+
const relationConfig = config.sql;
|
|
513
|
+
const childSchemaResult = createSchema(relationConfig.schema);
|
|
514
|
+
// Create the base schemas for the relation
|
|
515
|
+
let baseClientSchema;
|
|
516
|
+
let baseValidationSchema;
|
|
517
|
+
if (relationConfig.type === "hasMany" ||
|
|
518
|
+
relationConfig.type === "manyToMany") {
|
|
519
|
+
baseClientSchema = z.array(childSchemaResult.clientSchema).optional();
|
|
520
|
+
baseValidationSchema = z
|
|
521
|
+
.array(childSchemaResult.validationSchema)
|
|
522
|
+
.optional();
|
|
523
|
+
defaultValues[key] = Array.from({ length: relationConfig.defaultCount || 0 }, () => childSchemaResult.defaultValues);
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
baseClientSchema = childSchemaResult.clientSchema.optional();
|
|
527
|
+
baseValidationSchema = childSchemaResult.validationSchema.optional();
|
|
528
|
+
defaultValues[key] = childSchemaResult.defaultValues;
|
|
529
|
+
}
|
|
530
|
+
sqlFields[key] = z.array(childSchemaResult.sqlSchema).optional(); // SQL schema is never transformed by client
|
|
531
|
+
clientFields[key] = config.clientTransform
|
|
532
|
+
? config.clientTransform(baseClientSchema) // Apply the stored function
|
|
533
|
+
: baseClientSchema; // Or use the default if no transform exists
|
|
534
|
+
// Validation falls back to the client schema (which may have been transformed)
|
|
535
|
+
validationFields[key] = config.validationTransform
|
|
536
|
+
? config.validationTransform(baseValidationSchema)
|
|
537
|
+
: clientFields[key];
|
|
538
|
+
}
|
|
477
539
|
}
|
|
478
540
|
return {
|
|
479
541
|
sqlSchema: z.object(sqlFields),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cogsbox-shape",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.62",
|
|
4
4
|
"description": "A TypeScript library for creating type-safe database schemas with Zod validation, SQL type definitions, and automatic client/server transformations. Unifies client, server, and database types through a single schema definition, with built-in support for relationships and serialization.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|