cogsbox-shape 0.5.65 → 0.5.66

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.
@@ -1,552 +0,0 @@
1
- import { z } from "zod";
2
- export declare const petSchema: {
3
- _tableName: string;
4
- id: {
5
- config: {
6
- sql: {
7
- type: "int";
8
- pk: true;
9
- };
10
- zodSqlSchema: z.ZodNumber;
11
- zodNewSchema: z.ZodNumber;
12
- initialValue: string;
13
- zodClientSchema: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
14
- zodValidationSchema: z.ZodString;
15
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
16
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
17
- } & {
18
- transforms: {
19
- toClient: (dbValue: number) => number;
20
- toDb: (clientValue: number) => number;
21
- };
22
- };
23
- };
24
- name: import("../schema.js").Builder<"sql", {
25
- type: "varchar";
26
- length: number;
27
- }, z.ZodString, z.ZodString, string, z.ZodString, z.ZodString>;
28
- userId: {
29
- type: "reference";
30
- to: () => import("../schema.js").Builder<"sql", {
31
- type: "int";
32
- pk: true;
33
- }, z.ZodNumber, z.ZodNumber, number, z.ZodNumber, z.ZodNumber>;
34
- };
35
- fluffynessScale: {
36
- config: {
37
- sql: {
38
- type: "text";
39
- };
40
- zodSqlSchema: z.ZodString;
41
- zodNewSchema: z.ZodString;
42
- initialValue: string;
43
- zodClientSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
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;
47
- } & {
48
- transforms: {
49
- toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
50
- toDb: (clientValue: ("bald" | "fuzzy" | "fluffy" | "poof")[]) => string;
51
- };
52
- };
53
- };
54
- favourite: {
55
- config: {
56
- sql: {
57
- type: "int";
58
- };
59
- zodSqlSchema: z.ZodNumber;
60
- zodNewSchema: z.ZodNumber;
61
- initialValue: number;
62
- zodClientSchema: z.ZodBoolean;
63
- zodValidationSchema: z.ZodBoolean;
64
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
65
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
66
- } & {
67
- transforms: {
68
- toClient: (dbValue: number) => boolean;
69
- toDb: (clientValue: boolean) => number;
70
- };
71
- };
72
- };
73
- };
74
- export declare const userSchema: {
75
- _tableName: string;
76
- id: import("../schema.js").Builder<"sql", {
77
- type: "int";
78
- pk: true;
79
- }, z.ZodNumber, z.ZodNumber, number, z.ZodNumber, z.ZodNumber>;
80
- firstname: {
81
- config: {
82
- sql: {
83
- type: "varchar";
84
- length: number;
85
- };
86
- zodSqlSchema: z.ZodString;
87
- zodNewSchema: z.ZodString;
88
- initialValue: string;
89
- zodClientSchema: z.ZodString;
90
- zodValidationSchema: z.ZodString;
91
- };
92
- transform: (transforms: {
93
- toClient: (dbValue: string) => string;
94
- toDb: (clientValue: string) => string;
95
- }) => {
96
- config: {
97
- sql: {
98
- type: "varchar";
99
- length: number;
100
- };
101
- zodSqlSchema: z.ZodString;
102
- zodNewSchema: z.ZodString;
103
- initialValue: string;
104
- zodClientSchema: z.ZodString;
105
- zodValidationSchema: z.ZodString;
106
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
107
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
108
- } & {
109
- transforms: {
110
- toClient: (dbValue: string) => string;
111
- toDb: (clientValue: string) => string;
112
- };
113
- };
114
- };
115
- };
116
- surname: {
117
- config: {
118
- sql: {
119
- type: "varchar";
120
- length: number;
121
- };
122
- zodSqlSchema: z.ZodString;
123
- zodNewSchema: z.ZodString;
124
- initialValue: string;
125
- zodClientSchema: z.ZodString;
126
- zodValidationSchema: z.ZodString;
127
- };
128
- transform: (transforms: {
129
- toClient: (dbValue: string) => string;
130
- toDb: (clientValue: string) => string;
131
- }) => {
132
- config: {
133
- sql: {
134
- type: "varchar";
135
- length: number;
136
- };
137
- zodSqlSchema: z.ZodString;
138
- zodNewSchema: z.ZodString;
139
- initialValue: string;
140
- zodClientSchema: z.ZodString;
141
- zodValidationSchema: z.ZodString;
142
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
143
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
144
- } & {
145
- transforms: {
146
- toClient: (dbValue: string) => string;
147
- toDb: (clientValue: string) => string;
148
- };
149
- };
150
- };
151
- };
152
- email: {
153
- config: {
154
- sql: {
155
- type: "varchar";
156
- length: number;
157
- };
158
- zodSqlSchema: z.ZodString;
159
- zodNewSchema: z.ZodString;
160
- initialValue: string;
161
- zodClientSchema: z.ZodString;
162
- zodValidationSchema: z.ZodString;
163
- };
164
- transform: (transforms: {
165
- toClient: (dbValue: string) => string;
166
- toDb: (clientValue: string) => string;
167
- }) => {
168
- config: {
169
- sql: {
170
- type: "varchar";
171
- length: number;
172
- };
173
- zodSqlSchema: z.ZodString;
174
- zodNewSchema: z.ZodString;
175
- initialValue: string;
176
- zodClientSchema: z.ZodString;
177
- zodValidationSchema: z.ZodString;
178
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
179
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
180
- } & {
181
- transforms: {
182
- toClient: (dbValue: string) => string;
183
- toDb: (clientValue: string) => string;
184
- };
185
- };
186
- };
187
- };
188
- pets: {
189
- config: {
190
- sql: import("../schema.js").RelationConfig<{
191
- _tableName: string;
192
- id: {
193
- config: {
194
- sql: {
195
- type: "int";
196
- pk: true;
197
- };
198
- zodSqlSchema: z.ZodNumber;
199
- zodNewSchema: z.ZodNumber;
200
- initialValue: string;
201
- zodClientSchema: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
202
- zodValidationSchema: z.ZodString;
203
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
204
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
205
- } & {
206
- transforms: {
207
- toClient: (dbValue: number) => number;
208
- toDb: (clientValue: number) => number;
209
- };
210
- };
211
- };
212
- name: import("../schema.js").Builder<"sql", {
213
- type: "varchar";
214
- length: number;
215
- }, z.ZodString, z.ZodString, string, z.ZodString, z.ZodString>;
216
- userId: {
217
- type: "reference";
218
- to: () => import("../schema.js").Builder<"sql", {
219
- type: "int";
220
- pk: true;
221
- }, z.ZodNumber, z.ZodNumber, number, z.ZodNumber, z.ZodNumber>;
222
- };
223
- fluffynessScale: {
224
- config: {
225
- sql: {
226
- type: "text";
227
- };
228
- zodSqlSchema: z.ZodString;
229
- zodNewSchema: z.ZodString;
230
- initialValue: string;
231
- zodClientSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
232
- zodValidationSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
233
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
234
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
235
- } & {
236
- transforms: {
237
- toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
238
- toDb: (clientValue: ("bald" | "fuzzy" | "fluffy" | "poof")[]) => string;
239
- };
240
- };
241
- };
242
- favourite: {
243
- config: {
244
- sql: {
245
- type: "int";
246
- };
247
- zodSqlSchema: z.ZodNumber;
248
- zodNewSchema: z.ZodNumber;
249
- initialValue: number;
250
- zodClientSchema: z.ZodBoolean;
251
- zodValidationSchema: z.ZodBoolean;
252
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
253
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
254
- } & {
255
- transforms: {
256
- toClient: (dbValue: number) => boolean;
257
- toDb: (clientValue: boolean) => number;
258
- };
259
- };
260
- };
261
- }>;
262
- zodSqlSchema: z.ZodArray<z.ZodObject<{
263
- id: z.ZodNumber;
264
- name: z.ZodString;
265
- userId: z.ZodAny;
266
- fluffynessScale: z.ZodString;
267
- favourite: z.ZodNumber;
268
- }, z.UnknownKeysParam, z.ZodTypeAny, {
269
- name: string;
270
- id: number;
271
- fluffynessScale: string;
272
- favourite: number;
273
- userId?: any;
274
- }, {
275
- name: string;
276
- id: number;
277
- fluffynessScale: string;
278
- favourite: number;
279
- userId?: any;
280
- }>, "many">;
281
- zodNewSchema: z.ZodArray<z.ZodObject<{
282
- id: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
283
- name: z.ZodString;
284
- userId: z.ZodAny;
285
- fluffynessScale: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
286
- favourite: z.ZodBoolean;
287
- }, z.UnknownKeysParam, z.ZodTypeAny, {
288
- name: string;
289
- id: number;
290
- fluffynessScale: ("bald" | "fuzzy" | "fluffy" | "poof")[];
291
- favourite: boolean;
292
- userId?: any;
293
- }, {
294
- name: string;
295
- id: number;
296
- fluffynessScale: ("bald" | "fuzzy" | "fluffy" | "poof")[];
297
- favourite: boolean;
298
- userId?: any;
299
- }>, "many">;
300
- initialValue: any[];
301
- zodClientSchema: z.ZodArray<z.ZodObject<{
302
- id: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
303
- name: z.ZodString;
304
- userId: z.ZodAny;
305
- fluffynessScale: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
306
- favourite: z.ZodBoolean;
307
- }, z.UnknownKeysParam, z.ZodTypeAny, {
308
- name: string;
309
- id: number;
310
- fluffynessScale: ("bald" | "fuzzy" | "fluffy" | "poof")[];
311
- favourite: boolean;
312
- userId?: any;
313
- }, {
314
- name: string;
315
- id: number;
316
- fluffynessScale: ("bald" | "fuzzy" | "fluffy" | "poof")[];
317
- favourite: boolean;
318
- userId?: any;
319
- }>, "many">;
320
- zodValidationSchema: z.ZodArray<z.ZodObject<{
321
- id: z.ZodNumber;
322
- name: z.ZodString;
323
- userId: z.ZodAny;
324
- fluffynessScale: z.ZodString;
325
- favourite: z.ZodNumber;
326
- }, z.UnknownKeysParam, z.ZodTypeAny, {
327
- name: string;
328
- id: number;
329
- fluffynessScale: string;
330
- favourite: number;
331
- userId?: any;
332
- }, {
333
- name: string;
334
- id: number;
335
- fluffynessScale: string;
336
- favourite: number;
337
- userId?: any;
338
- }>, "many">;
339
- };
340
- transform: (transforms: {
341
- toClient: (dbValue: {
342
- name: string;
343
- id: number;
344
- fluffynessScale: string;
345
- favourite: number;
346
- userId?: any;
347
- }[]) => {
348
- name: string;
349
- id: number;
350
- fluffynessScale: ("bald" | "fuzzy" | "fluffy" | "poof")[];
351
- favourite: boolean;
352
- userId?: any;
353
- }[];
354
- toDb: (clientValue: {
355
- name: string;
356
- id: number;
357
- fluffynessScale: ("bald" | "fuzzy" | "fluffy" | "poof")[];
358
- favourite: boolean;
359
- userId?: any;
360
- }[]) => {
361
- name: string;
362
- id: number;
363
- fluffynessScale: string;
364
- favourite: number;
365
- userId?: any;
366
- }[];
367
- }) => {
368
- config: {
369
- sql: import("../schema.js").RelationConfig<{
370
- _tableName: string;
371
- id: {
372
- config: {
373
- sql: {
374
- type: "int";
375
- pk: true;
376
- };
377
- zodSqlSchema: z.ZodNumber;
378
- zodNewSchema: z.ZodNumber;
379
- initialValue: string;
380
- zodClientSchema: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
381
- zodValidationSchema: z.ZodString;
382
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
383
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
384
- } & {
385
- transforms: {
386
- toClient: (dbValue: number) => number;
387
- toDb: (clientValue: number) => number;
388
- };
389
- };
390
- };
391
- name: import("../schema.js").Builder<"sql", {
392
- type: "varchar";
393
- length: number;
394
- }, z.ZodString, z.ZodString, string, z.ZodString, z.ZodString>;
395
- userId: {
396
- type: "reference";
397
- to: () => import("../schema.js").Builder<"sql", {
398
- type: "int";
399
- pk: true;
400
- }, z.ZodNumber, z.ZodNumber, number, z.ZodNumber, z.ZodNumber>;
401
- };
402
- fluffynessScale: {
403
- config: {
404
- sql: {
405
- type: "text";
406
- };
407
- zodSqlSchema: z.ZodString;
408
- zodNewSchema: z.ZodString;
409
- initialValue: string;
410
- zodClientSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
411
- zodValidationSchema: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
412
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
413
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
414
- } & {
415
- transforms: {
416
- toClient: (dbValue: string) => ("bald" | "fuzzy" | "fluffy" | "poof")[];
417
- toDb: (clientValue: ("bald" | "fuzzy" | "fluffy" | "poof")[]) => string;
418
- };
419
- };
420
- };
421
- favourite: {
422
- config: {
423
- sql: {
424
- type: "int";
425
- };
426
- zodSqlSchema: z.ZodNumber;
427
- zodNewSchema: z.ZodNumber;
428
- initialValue: number;
429
- zodClientSchema: z.ZodBoolean;
430
- zodValidationSchema: z.ZodBoolean;
431
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
432
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
433
- } & {
434
- transforms: {
435
- toClient: (dbValue: number) => boolean;
436
- toDb: (clientValue: boolean) => number;
437
- };
438
- };
439
- };
440
- }>;
441
- zodSqlSchema: z.ZodArray<z.ZodObject<{
442
- id: z.ZodNumber;
443
- name: z.ZodString;
444
- userId: z.ZodAny;
445
- fluffynessScale: z.ZodString;
446
- favourite: z.ZodNumber;
447
- }, z.UnknownKeysParam, z.ZodTypeAny, {
448
- name: string;
449
- id: number;
450
- fluffynessScale: string;
451
- favourite: number;
452
- userId?: any;
453
- }, {
454
- name: string;
455
- id: number;
456
- fluffynessScale: string;
457
- favourite: number;
458
- userId?: any;
459
- }>, "many">;
460
- zodNewSchema: z.ZodArray<z.ZodObject<{
461
- id: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
462
- name: z.ZodString;
463
- userId: z.ZodAny;
464
- fluffynessScale: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
465
- favourite: z.ZodBoolean;
466
- }, z.UnknownKeysParam, z.ZodTypeAny, {
467
- name: string;
468
- id: number;
469
- fluffynessScale: ("bald" | "fuzzy" | "fluffy" | "poof")[];
470
- favourite: boolean;
471
- userId?: any;
472
- }, {
473
- name: string;
474
- id: number;
475
- fluffynessScale: ("bald" | "fuzzy" | "fluffy" | "poof")[];
476
- favourite: boolean;
477
- userId?: any;
478
- }>, "many">;
479
- initialValue: any[];
480
- zodClientSchema: z.ZodArray<z.ZodObject<{
481
- id: z.ZodUnion<[z.ZodNumber, z.ZodNumber]>;
482
- name: z.ZodString;
483
- userId: z.ZodAny;
484
- fluffynessScale: z.ZodArray<z.ZodEnum<["bald", "fuzzy", "fluffy", "poof"]>, "many">;
485
- favourite: z.ZodBoolean;
486
- }, z.UnknownKeysParam, z.ZodTypeAny, {
487
- name: string;
488
- id: number;
489
- fluffynessScale: ("bald" | "fuzzy" | "fluffy" | "poof")[];
490
- favourite: boolean;
491
- userId?: any;
492
- }, {
493
- name: string;
494
- id: number;
495
- fluffynessScale: ("bald" | "fuzzy" | "fluffy" | "poof")[];
496
- favourite: boolean;
497
- userId?: any;
498
- }>, "many">;
499
- zodValidationSchema: z.ZodArray<z.ZodObject<{
500
- id: z.ZodNumber;
501
- name: z.ZodString;
502
- userId: z.ZodAny;
503
- fluffynessScale: z.ZodString;
504
- favourite: z.ZodNumber;
505
- }, z.UnknownKeysParam, z.ZodTypeAny, {
506
- name: string;
507
- id: number;
508
- fluffynessScale: string;
509
- favourite: number;
510
- userId?: any;
511
- }, {
512
- name: string;
513
- id: number;
514
- fluffynessScale: string;
515
- favourite: number;
516
- userId?: any;
517
- }>, "many">;
518
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
519
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
520
- } & {
521
- transforms: {
522
- toClient: (dbValue: {
523
- name: string;
524
- id: number;
525
- fluffynessScale: string;
526
- favourite: number;
527
- userId?: any;
528
- }[]) => {
529
- name: string;
530
- id: number;
531
- fluffynessScale: ("bald" | "fuzzy" | "fluffy" | "poof")[];
532
- favourite: boolean;
533
- userId?: any;
534
- }[];
535
- toDb: (clientValue: {
536
- name: string;
537
- id: number;
538
- fluffynessScale: ("bald" | "fuzzy" | "fluffy" | "poof")[];
539
- favourite: boolean;
540
- userId?: any;
541
- }[]) => {
542
- name: string;
543
- id: number;
544
- fluffynessScale: string;
545
- favourite: number;
546
- userId?: any;
547
- }[];
548
- };
549
- };
550
- };
551
- };
552
- };
@@ -1,77 +0,0 @@
1
- import { z } from "zod";
2
- import { createSchema, hasMany, reference, shape, } from "../schema.js";
3
- export const petSchema = {
4
- _tableName: "pets",
5
- id: shape
6
- .sql({ type: "int", pk: true })
7
- .initialState(() => "uuidexample")
8
- .client(({ sql, initialState }) => z.union([sql, initialState]))
9
- .validation(z.string())
10
- .transform({
11
- toClient: (dbValue) => dbValue,
12
- toDb: (clientValue) => Number(clientValue),
13
- }),
14
- name: shape.sql({ type: "varchar", length: 255 }),
15
- userId: reference(() => userSchema.id),
16
- fluffynessScale: shape
17
- .sql({ type: "text" })
18
- .client(({ sql }) => z.array(z.enum(["bald", "fuzzy", "fluffy", "poof"])))
19
- .transform({
20
- toClient: (value) => value.split(",").filter(Boolean),
21
- toDb: (value) => value.join(","),
22
- }),
23
- favourite: shape
24
- .sql({ type: "int" })
25
- .client(({ sql }) => z.boolean())
26
- .transform({
27
- toClient: (dbValue) => dbValue === 1,
28
- toDb: (clientValue) => (clientValue ? 1 : 0),
29
- }),
30
- };
31
- export const userSchema = {
32
- //The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.
33
- _tableName: "users",
34
- id: shape.sql({ type: "int", pk: true }),
35
- firstname: shape
36
- .sql({ type: "varchar", length: 255 })
37
- .initialState(() => "test")
38
- .validation(({ sql }) => sql.min(1)),
39
- surname: shape
40
- .sql({ type: "varchar", length: 255 })
41
- .validation(({ sql }) => sql.min(1)),
42
- email: shape
43
- .sql({ type: "varchar", length: 255 })
44
- .validation(({ sql }) => sql.email()),
45
- pets: shape
46
- .hasMany({
47
- fromKey: "id",
48
- toKey: () => petSchema.userId,
49
- schema: () => petSchema,
50
- defaultCount: 1,
51
- })
52
- .validation(({ sql }) => sql.min(1)),
53
- };
54
- const testPets = {
55
- _tableName: "users",
56
- id: shape
57
- .sql({ type: "int", pk: true })
58
- .initialState(z.string().uuid(), () => "sdasdsad")
59
- .client(({ sql, initialState }) => z.union([sql, initialState]))
60
- .validation(({ sql }) => sql)
61
- .transform({
62
- toClient: (dbValue) => dbValue,
63
- toDb: (clientValue) => Number(clientValue),
64
- }),
65
- email: shape
66
- .sql({ type: "varchar", length: 255 })
67
- .validation(({ sql }) => sql),
68
- createdAt: shape
69
- .sql({ type: "datetime" })
70
- .client(({ sql }) => z.string())
71
- .validation(({ sql }) => sql.optional())
72
- .transform({
73
- toClient: (date) => date.toISOString(),
74
- toDb: (str) => new Date(str),
75
- }),
76
- };
77
- const { sqlSchema, clientSchema: clSchema, defaultValues, validationSchema, } = createSchema(userSchema);