cogsbox-shape 0.5.10 → 0.5.11

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.
@@ -54,9 +54,9 @@ declare const schemas: {
54
54
  };
55
55
  };
56
56
  };
57
- db: <ServerType extends import("zod").ZodTypeAny>(assert: (tools: {
57
+ db: <ServerType extends import("zod").ZodTypeAny>(assert: ServerType | ((tools: {
58
58
  zod: import("zod").ZodNumber;
59
- }) => ServerType) => {
59
+ }) => ServerType)) => {
60
60
  sql: {
61
61
  type: "int";
62
62
  pk: true;
@@ -357,9 +357,9 @@ declare const schemas: {
357
357
  };
358
358
  };
359
359
  };
360
- db: <ServerType extends import("zod").ZodTypeAny>(assert: (tools: {
360
+ db: <ServerType extends import("zod").ZodTypeAny>(assert: ServerType | ((tools: {
361
361
  zod: import("zod").ZodString;
362
- }) => ServerType) => {
362
+ }) => ServerType)) => {
363
363
  sql: {
364
364
  type: "varchar";
365
365
  length: number;
@@ -552,9 +552,9 @@ declare const schemas: {
552
552
  };
553
553
  };
554
554
  };
555
- db: <ServerType extends import("zod").ZodTypeAny>(assert: (tools: {
555
+ db: <ServerType extends import("zod").ZodTypeAny>(assert: ServerType | ((tools: {
556
556
  zod: import("zod").ZodString;
557
- }) => ServerType) => {
557
+ }) => ServerType)) => {
558
558
  sql: {
559
559
  type: "varchar";
560
560
  length: number;
@@ -754,9 +754,9 @@ declare const schemas: {
754
754
  };
755
755
  };
756
756
  };
757
- db: <ServerType extends import("zod").ZodTypeAny>(assert: (tools: {
757
+ db: <ServerType extends import("zod").ZodTypeAny>(assert: ServerType | ((tools: {
758
758
  zod: import("zod").ZodString;
759
- }) => ServerType) => {
759
+ }) => ServerType)) => {
760
760
  sql: {
761
761
  type: "varchar";
762
762
  length: number;
@@ -54,9 +54,9 @@ export declare const userSchema: {
54
54
  };
55
55
  };
56
56
  };
57
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
57
+ db: <ServerType extends z.ZodTypeAny>(assert: ServerType | ((tools: {
58
58
  zod: z.ZodNumber;
59
- }) => ServerType) => {
59
+ }) => ServerType)) => {
60
60
  sql: {
61
61
  type: "int";
62
62
  pk: true;
@@ -357,9 +357,9 @@ export declare const userSchema: {
357
357
  };
358
358
  };
359
359
  };
360
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
360
+ db: <ServerType extends z.ZodTypeAny>(assert: ServerType | ((tools: {
361
361
  zod: z.ZodString;
362
- }) => ServerType) => {
362
+ }) => ServerType)) => {
363
363
  sql: {
364
364
  type: "varchar";
365
365
  length: number;
@@ -552,9 +552,9 @@ export declare const userSchema: {
552
552
  };
553
553
  };
554
554
  };
555
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
555
+ db: <ServerType extends z.ZodTypeAny>(assert: ServerType | ((tools: {
556
556
  zod: z.ZodString;
557
- }) => ServerType) => {
557
+ }) => ServerType)) => {
558
558
  sql: {
559
559
  type: "varchar";
560
560
  length: number;
@@ -754,9 +754,9 @@ export declare const petSchema: {
754
754
  };
755
755
  };
756
756
  };
757
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
757
+ db: <ServerType extends z.ZodTypeAny>(assert: ServerType | ((tools: {
758
758
  zod: z.ZodString;
759
- }) => ServerType) => {
759
+ }) => ServerType)) => {
760
760
  sql: {
761
761
  type: "varchar";
762
762
  length: number;
package/dist/schema.d.ts CHANGED
@@ -196,9 +196,9 @@ export declare const shape: {
196
196
  };
197
197
  };
198
198
  };
199
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
199
+ db: <ServerType extends z.ZodTypeAny>(assert: ServerType | ((tools: {
200
200
  zod: z.ZodNumber;
201
- }) => ServerType) => {
201
+ }) => ServerType)) => {
202
202
  sql: {
203
203
  nullable?: boolean;
204
204
  pk?: true;
@@ -315,9 +315,9 @@ export declare const shape: {
315
315
  };
316
316
  };
317
317
  };
318
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
318
+ db: <ServerType extends z.ZodTypeAny>(assert: ServerType | ((tools: {
319
319
  zod: z.ZodString;
320
- }) => ServerType) => {
320
+ }) => ServerType)) => {
321
321
  sql: {
322
322
  nullable?: boolean;
323
323
  default?: string;
@@ -437,9 +437,9 @@ export declare const shape: {
437
437
  };
438
438
  };
439
439
  };
440
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
440
+ db: <ServerType extends z.ZodTypeAny>(assert: ServerType | ((tools: {
441
441
  zod: z.ZodString;
442
- }) => ServerType) => {
442
+ }) => ServerType)) => {
443
443
  sql: {
444
444
  nullable?: boolean;
445
445
  default?: string;
@@ -556,9 +556,9 @@ export declare const shape: {
556
556
  };
557
557
  };
558
558
  };
559
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
559
+ db: <ServerType extends z.ZodTypeAny>(assert: ServerType | ((tools: {
560
560
  zod: z.ZodString;
561
- }) => ServerType) => {
561
+ }) => ServerType)) => {
562
562
  sql: {
563
563
  nullable?: boolean;
564
564
  default?: string;
@@ -672,9 +672,9 @@ export declare const shape: {
672
672
  };
673
673
  };
674
674
  };
675
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
675
+ db: <ServerType extends z.ZodTypeAny>(assert: ServerType | ((tools: {
676
676
  zod: z.ZodString;
677
- }) => ServerType) => {
677
+ }) => ServerType)) => {
678
678
  sql: {
679
679
  nullable?: boolean;
680
680
  default?: string;
@@ -788,9 +788,9 @@ export declare const shape: {
788
788
  };
789
789
  };
790
790
  };
791
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
791
+ db: <ServerType extends z.ZodTypeAny>(assert: ServerType | ((tools: {
792
792
  zod: z.ZodBoolean;
793
- }) => ServerType) => {
793
+ }) => ServerType)) => {
794
794
  sql: {
795
795
  nullable?: boolean;
796
796
  pk?: true;
@@ -904,9 +904,9 @@ export declare const shape: {
904
904
  };
905
905
  };
906
906
  };
907
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
907
+ db: <ServerType extends z.ZodTypeAny>(assert: ServerType | ((tools: {
908
908
  zod: z.ZodDate;
909
- }) => ServerType) => {
909
+ }) => ServerType)) => {
910
910
  sql: {
911
911
  nullable?: boolean;
912
912
  default?: Date;
@@ -1020,9 +1020,9 @@ export declare const shape: {
1020
1020
  };
1021
1021
  };
1022
1022
  };
1023
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
1023
+ db: <ServerType extends z.ZodTypeAny>(assert: ServerType | ((tools: {
1024
1024
  zod: z.ZodDate;
1025
- }) => ServerType) => {
1025
+ }) => ServerType)) => {
1026
1026
  sql: {
1027
1027
  nullable?: boolean;
1028
1028
  default?: Date;
@@ -1118,9 +1118,9 @@ export declare const shape: {
1118
1118
  };
1119
1119
  };
1120
1120
  };
1121
- db: <ServerType extends z.ZodTypeAny>(assert: (tools: {
1121
+ db: <ServerType extends z.ZodTypeAny>(assert: ((tools: {
1122
1122
  zod: SQLToZodType<T, false>;
1123
- }) => ServerType) => {
1123
+ }) => ServerType) | ServerType) => {
1124
1124
  sql: T;
1125
1125
  dbType: ServerType;
1126
1126
  zodDbSchema: ServerType;
package/dist/schema.js CHANGED
@@ -210,7 +210,9 @@ export const shape = {
210
210
  baseJsonSchema: jsonSchema,
211
211
  }),
212
212
  db: (assert) => {
213
- const serverType = assert({ zod: inferredDbType });
213
+ const serverType = isFunction(assert)
214
+ ? assert({ zod: inferredDbType })
215
+ : assert;
214
216
  return {
215
217
  sql: sqlConfig,
216
218
  dbType: serverType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
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",