@mirite/zod-to-mongoose 0.0.5 → 0.0.6
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/_tsup-dts-rollup.d.cts +38 -38
- package/dist/_tsup-dts-rollup.d.ts +38 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +14 -13
- package/readme.md +6 -6
- package/dist/src/index.d.cts +0 -1
- package/dist/src/index.d.ts +0 -1
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import * as Mongoose from 'mongoose';
|
|
2
|
-
import type { z } from 'zod';
|
|
3
|
-
import type { ZodBoolean } from 'zod';
|
|
4
|
-
import type { ZodDate } from 'zod';
|
|
5
|
-
import type { ZodDefault } from 'zod';
|
|
6
|
-
import type { ZodNumber } from 'zod';
|
|
7
|
-
import type { ZodObject } from 'zod';
|
|
8
|
-
import type { ZodRawShape } from 'zod';
|
|
9
|
-
import type { ZodString } from 'zod';
|
|
10
|
-
import type { ZodTypeAny } from 'zod';
|
|
11
|
-
import type { ZodUnion } from 'zod';
|
|
12
|
-
|
|
13
|
-
export declare type Check = "";
|
|
14
|
-
|
|
15
|
-
export declare function createSchema<T extends ZodRawShape>(zodObject: ZodObject<T>, modelName: string, connection: Mongoose.Connection): {
|
|
16
|
-
schema: Mongoose.Schema;
|
|
17
|
-
model: Mongoose.Model<z.infer<typeof zodObject>>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export declare function createSchema<T extends ZodRawShape>(zodObject: ZodObject<T>): Mongoose.Schema;
|
|
21
|
-
|
|
22
|
-
export declare type Field = {
|
|
23
|
-
_def: FieldDefinition;
|
|
24
|
-
checks?: Array<Check>;
|
|
25
|
-
defaultValue?: () => unknown;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export declare type FieldDefinition = {
|
|
29
|
-
typeName: string;
|
|
30
|
-
innerType?: Field;
|
|
31
|
-
description: string | undefined;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
declare type SupportedPrimitive = ZodString | ZodNumber | ZodBoolean | ZodDate;
|
|
35
|
-
|
|
36
|
-
export declare type SupportedType = SupportedPrimitive | ZodDefault<ZodTypeAny> | ZodObject<ZodRawShape> | ZodUnion<readonly [ZodTypeAny, ...ZodTypeAny[]]>;
|
|
37
|
-
|
|
38
|
-
export { }
|
|
1
|
+
import * as Mongoose from 'mongoose';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { ZodBoolean } from 'zod';
|
|
4
|
+
import type { ZodDate } from 'zod';
|
|
5
|
+
import type { ZodDefault } from 'zod';
|
|
6
|
+
import type { ZodNumber } from 'zod';
|
|
7
|
+
import type { ZodObject } from 'zod';
|
|
8
|
+
import type { ZodRawShape } from 'zod';
|
|
9
|
+
import type { ZodString } from 'zod';
|
|
10
|
+
import type { ZodTypeAny } from 'zod';
|
|
11
|
+
import type { ZodUnion } from 'zod';
|
|
12
|
+
|
|
13
|
+
export declare type Check = "";
|
|
14
|
+
|
|
15
|
+
export declare function createSchema<T extends ZodRawShape>(zodObject: ZodObject<T>, modelName: string, connection: Mongoose.Connection): {
|
|
16
|
+
schema: Mongoose.Schema;
|
|
17
|
+
model: Mongoose.Model<z.infer<typeof zodObject>>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export declare function createSchema<T extends ZodRawShape>(zodObject: ZodObject<T>): Mongoose.Schema;
|
|
21
|
+
|
|
22
|
+
export declare type Field = {
|
|
23
|
+
_def: FieldDefinition;
|
|
24
|
+
checks?: Array<Check>;
|
|
25
|
+
defaultValue?: () => unknown;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export declare type FieldDefinition = {
|
|
29
|
+
typeName: string;
|
|
30
|
+
innerType?: Field;
|
|
31
|
+
description: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
declare type SupportedPrimitive = ZodString | ZodNumber | ZodBoolean | ZodDate;
|
|
35
|
+
|
|
36
|
+
export declare type SupportedType = SupportedPrimitive | ZodDefault<ZodTypeAny> | ZodObject<ZodRawShape> | ZodUnion<readonly [ZodTypeAny, ...ZodTypeAny[]]>;
|
|
37
|
+
|
|
38
|
+
export { }
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import * as Mongoose from 'mongoose';
|
|
2
|
-
import type { z } from 'zod';
|
|
3
|
-
import type { ZodBoolean } from 'zod';
|
|
4
|
-
import type { ZodDate } from 'zod';
|
|
5
|
-
import type { ZodDefault } from 'zod';
|
|
6
|
-
import type { ZodNumber } from 'zod';
|
|
7
|
-
import type { ZodObject } from 'zod';
|
|
8
|
-
import type { ZodRawShape } from 'zod';
|
|
9
|
-
import type { ZodString } from 'zod';
|
|
10
|
-
import type { ZodTypeAny } from 'zod';
|
|
11
|
-
import type { ZodUnion } from 'zod';
|
|
12
|
-
|
|
13
|
-
export declare type Check = "";
|
|
14
|
-
|
|
15
|
-
export declare function createSchema<T extends ZodRawShape>(zodObject: ZodObject<T>, modelName: string, connection: Mongoose.Connection): {
|
|
16
|
-
schema: Mongoose.Schema;
|
|
17
|
-
model: Mongoose.Model<z.infer<typeof zodObject>>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export declare function createSchema<T extends ZodRawShape>(zodObject: ZodObject<T>): Mongoose.Schema;
|
|
21
|
-
|
|
22
|
-
export declare type Field = {
|
|
23
|
-
_def: FieldDefinition;
|
|
24
|
-
checks?: Array<Check>;
|
|
25
|
-
defaultValue?: () => unknown;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export declare type FieldDefinition = {
|
|
29
|
-
typeName: string;
|
|
30
|
-
innerType?: Field;
|
|
31
|
-
description: string | undefined;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
declare type SupportedPrimitive = ZodString | ZodNumber | ZodBoolean | ZodDate;
|
|
35
|
-
|
|
36
|
-
export declare type SupportedType = SupportedPrimitive | ZodDefault<ZodTypeAny> | ZodObject<ZodRawShape> | ZodUnion<readonly [ZodTypeAny, ...ZodTypeAny[]]>;
|
|
37
|
-
|
|
38
|
-
export { }
|
|
1
|
+
import * as Mongoose from 'mongoose';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { ZodBoolean } from 'zod';
|
|
4
|
+
import type { ZodDate } from 'zod';
|
|
5
|
+
import type { ZodDefault } from 'zod';
|
|
6
|
+
import type { ZodNumber } from 'zod';
|
|
7
|
+
import type { ZodObject } from 'zod';
|
|
8
|
+
import type { ZodRawShape } from 'zod';
|
|
9
|
+
import type { ZodString } from 'zod';
|
|
10
|
+
import type { ZodTypeAny } from 'zod';
|
|
11
|
+
import type { ZodUnion } from 'zod';
|
|
12
|
+
|
|
13
|
+
export declare type Check = "";
|
|
14
|
+
|
|
15
|
+
export declare function createSchema<T extends ZodRawShape>(zodObject: ZodObject<T>, modelName: string, connection: Mongoose.Connection): {
|
|
16
|
+
schema: Mongoose.Schema;
|
|
17
|
+
model: Mongoose.Model<z.infer<typeof zodObject>>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export declare function createSchema<T extends ZodRawShape>(zodObject: ZodObject<T>): Mongoose.Schema;
|
|
21
|
+
|
|
22
|
+
export declare type Field = {
|
|
23
|
+
_def: FieldDefinition;
|
|
24
|
+
checks?: Array<Check>;
|
|
25
|
+
defaultValue?: () => unknown;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export declare type FieldDefinition = {
|
|
29
|
+
typeName: string;
|
|
30
|
+
innerType?: Field;
|
|
31
|
+
description: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
declare type SupportedPrimitive = ZodString | ZodNumber | ZodBoolean | ZodDate;
|
|
35
|
+
|
|
36
|
+
export declare type SupportedType = SupportedPrimitive | ZodDefault<ZodTypeAny> | ZodObject<ZodRawShape> | ZodUnion<readonly [ZodTypeAny, ...ZodTypeAny[]]>;
|
|
37
|
+
|
|
38
|
+
export { }
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import * as Mongoose from \"mongoose\";\nimport type { SchemaDefinition } from \"mongoose\";\nimport type { z, ZodObject, ZodRawShape } from \"zod\";\n\nimport type { SupportedType } from \"./types\";\n\nexport function createSchema<T extends ZodRawShape>(\n zodObject: ZodObject<T>,\n modelName: string,\n connection: Mongoose.Connection,\n): { schema: Mongoose.Schema; model: Mongoose.Model<z.infer<typeof zodObject>> };\nexport function createSchema<T extends ZodRawShape>(zodObject: ZodObject<T>): Mongoose.Schema;\n/**\n * Create a Mongoose schema from a Zod shape\n *\n * @template T The Zod schema shape.\n * @param zodObject The Zod shape to create the schema from\n * @param modelName The unique name to assign to the model\n * @param connection The Mongoose connection to create the model from\n * @returns The Mongoose schema\n */\nexport function createSchema<T extends ZodRawShape>(\n zodObject: ZodObject<T>,\n modelName?: string,\n connection?: Mongoose.Connection,\n): Mongoose.Schema | { schema: Mongoose.Schema; model: Mongoose.Model<z.infer<typeof zodObject>> } {\n const convertedShape: Partial<SchemaDefinition> = {};\n for (const key in zodObject.shape) {\n const zodField = zodObject.shape[key];\n convertedShape[key] = convertField(key, zodField);\n }\n const schema = new Mongoose.Schema(convertedShape);\n if (!connection || !modelName) return schema;\n return { schema, model: connection.model<z.infer<typeof zodObject>>(modelName, schema) };\n}\n\n/**\n * Check if a Zod definition is an object\n *\n * @param definition The Zod definition to check\n * @returns Whether the definition is an object\n */\nfunction isZodObject(definition: SupportedType): definition is ZodObject<ZodRawShape> {\n return definition._def.typeName === \"ZodObject\";\n}\n\n/**\n * Convert a Zod field to a Mongoose type\n *\n * @template T The Zod schema shape.\n * @param type The key of the field\n * @param zodField The Zod field to convert\n * @returns The Mongoose type\n * @throws TypeError If the type is not supported.\n */\nfunction convertField<T extends ZodRawShape>(type: string, zodField: T[Extract<keyof T, string>]) {\n const unwrappedData = unwrapType(zodField);\n let coreType;\n switch (unwrappedData.definition._def.typeName) {\n case \"ZodString\":\n coreType = String;\n break;\n case \"ZodNumber\":\n coreType = Number;\n break;\n case \"ZodBoolean\":\n coreType = Boolean;\n break;\n case \"ZodDate\":\n coreType = Date;\n break;\n case \"ZodObject\":\n break;\n case \"ZodUnion\":\n coreType = {};\n break;\n default:\n throw new TypeError(`Unsupported type: ${type}`);\n }\n if (isZodObject(unwrappedData.definition)) {\n coreType = createSchema(unwrappedData.definition);\n }\n\n if (!unwrappedData.defaultValue) {\n return coreType;\n }\n return {\n type: coreType,\n default: unwrappedData.defaultValue,\n };\n}\n\n/**\n * Takes a complex type and returns the inner type definition along with the default if present.\n *\n * @param data The type data to unwrap.\n * @returns The inner type data along with the default if present.\n */\nfunction unwrapType(data: SupportedType): { definition: SupportedType; optional: boolean; defaultValue?: unknown } {\n let definition = data;\n const optional = false;\n let defaultValue = undefined;\n while (\"innerType\" in definition._def) {\n if (\"defaultValue\" in definition._def) {\n defaultValue = definition._def.defaultValue();\n }\n definition = definition._def.innerType;\n }\n return { definition, optional, defaultValue };\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,yBAqBnB,SAASF,EACZG,EACAC,EACAC,EAC+F,CAC/F,IAAMC,EAA4C,CAAC,EACnD,QAAWC,KAAOJ,EAAU,MAAO,CAC/B,IAAMK,EAAWL,EAAU,MAAMI,CAAG,EACpCD,EAAeC,CAAG,EAAIE,EAAaF,EAAKC,CAAQ,CACpD,CACA,IAAME,EAAS,IAAa,SAAOJ,CAAc,EACjD,MAAI,CAACD,GAAc,CAACD,EAAkBM,EAC/B,CAAE,OAAAA,EAAQ,MAAOL,EAAW,MAAiCD,EAAWM,CAAM,CAAE,CAC3F,CAQA,SAASC,EAAYC,EAAiE,CAClF,OAAOA,EAAW,KAAK,WAAa,WACxC,CAWA,SAASH,EAAoCI,EAAcL,EAAuC,CAC9F,IAAMM,EAAgBC,EAAWP,CAAQ,EACrCQ,EACJ,OAAQF,EAAc,WAAW,KAAK,SAAU,CAC5C,IAAK,YACDE,EAAW,OACX,MACJ,IAAK,YACDA,EAAW,OACX,MACJ,IAAK,aACDA,EAAW,QACX,MACJ,IAAK,UACDA,EAAW,KACX,MACJ,IAAK,YACD,MACJ,IAAK,WACDA,EAAW,CAAC,EACZ,MACJ,QACI,MAAM,IAAI,UAAU,qBAAqBH,CAAI,EAAE,CACvD,CAKA,OAJIF,EAAYG,EAAc,UAAU,IACpCE,EAAWhB,EAAac,EAAc,UAAU,GAG/CA,EAAc,aAGZ,CACH,KAAME,EACN,QAASF,EAAc,YAC3B,EALWE,CAMf,CAQA,SAASD,EAAWE,EAA+F,CAC/G,IAAIL,EAAaK,EACXC,EAAW,GACbC,EACJ,KAAO,cAAeP,EAAW,MACzB,iBAAkBA,EAAW,OAC7BO,EAAeP,EAAW,KAAK,aAAa,GAEhDA,EAAaA,EAAW,KAAK,UAEjC,MAAO,CAAE,WAAAA,EAAY,SAAAM,EAAU,aAAAC,CAAa,CAChD","names":["
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import * as Mongoose from \"mongoose\";\nimport type { SchemaDefinition } from \"mongoose\";\nimport type { z, ZodObject, ZodRawShape } from \"zod\";\n\nimport type { SupportedType } from \"./types\";\n\nexport function createSchema<T extends ZodRawShape>(\n zodObject: ZodObject<T>,\n modelName: string,\n connection: Mongoose.Connection,\n): { schema: Mongoose.Schema; model: Mongoose.Model<z.infer<typeof zodObject>> };\nexport function createSchema<T extends ZodRawShape>(zodObject: ZodObject<T>): Mongoose.Schema;\n/**\n * Create a Mongoose schema from a Zod shape\n *\n * @template T The Zod schema shape.\n * @param zodObject The Zod shape to create the schema from\n * @param modelName The unique name to assign to the model\n * @param connection The Mongoose connection to create the model from\n * @returns The Mongoose schema\n */\nexport function createSchema<T extends ZodRawShape>(\n zodObject: ZodObject<T>,\n modelName?: string,\n connection?: Mongoose.Connection,\n): Mongoose.Schema | { schema: Mongoose.Schema; model: Mongoose.Model<z.infer<typeof zodObject>> } {\n const convertedShape: Partial<SchemaDefinition> = {};\n for (const key in zodObject.shape) {\n const zodField = zodObject.shape[key];\n convertedShape[key] = convertField(key, zodField);\n }\n const schema = new Mongoose.Schema(convertedShape);\n if (!connection || !modelName) return schema;\n return { schema, model: connection.model<z.infer<typeof zodObject>>(modelName, schema) };\n}\n\n/**\n * Check if a Zod definition is an object\n *\n * @param definition The Zod definition to check\n * @returns Whether the definition is an object\n */\nfunction isZodObject(definition: SupportedType): definition is ZodObject<ZodRawShape> {\n return definition._def.typeName === \"ZodObject\";\n}\n\n/**\n * Convert a Zod field to a Mongoose type\n *\n * @template T The Zod schema shape.\n * @param type The key of the field\n * @param zodField The Zod field to convert\n * @returns The Mongoose type\n * @throws TypeError If the type is not supported.\n */\nfunction convertField<T extends ZodRawShape>(type: string, zodField: T[Extract<keyof T, string>]) {\n const unwrappedData = unwrapType(zodField);\n let coreType;\n switch (unwrappedData.definition._def.typeName) {\n case \"ZodString\":\n coreType = String;\n break;\n case \"ZodNumber\":\n coreType = Number;\n break;\n case \"ZodBoolean\":\n coreType = Boolean;\n break;\n case \"ZodDate\":\n coreType = Date;\n break;\n case \"ZodObject\":\n break;\n case \"ZodUnion\":\n coreType = {};\n break;\n default:\n throw new TypeError(`Unsupported type: ${type}`);\n }\n if (isZodObject(unwrappedData.definition)) {\n coreType = createSchema(unwrappedData.definition);\n }\n\n if (!unwrappedData.defaultValue) {\n return coreType;\n }\n return {\n type: coreType,\n default: unwrappedData.defaultValue,\n };\n}\n\n/**\n * Takes a complex type and returns the inner type definition along with the default if present.\n *\n * @param data The type data to unwrap.\n * @returns The inner type data along with the default if present.\n */\nfunction unwrapType(data: SupportedType): { definition: SupportedType; optional: boolean; defaultValue?: unknown } {\n let definition = data;\n const optional = false;\n let defaultValue = undefined;\n while (\"innerType\" in definition._def) {\n if (\"defaultValue\" in definition._def) {\n defaultValue = definition._def.defaultValue();\n }\n definition = definition._def.innerType;\n }\n return { definition, optional, defaultValue };\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,yBAqBnB,SAASF,EACZG,EACAC,EACAC,EAC+F,CAC/F,IAAMC,EAA4C,CAAC,EACnD,QAAWC,KAAOJ,EAAU,MAAO,CAC/B,IAAMK,EAAWL,EAAU,MAAMI,CAAG,EACpCD,EAAeC,CAAG,EAAIE,EAAaF,EAAKC,CAAQ,CACpD,CACA,IAAME,EAAS,IAAa,SAAOJ,CAAc,EACjD,MAAI,CAACD,GAAc,CAACD,EAAkBM,EAC/B,CAAE,OAAAA,EAAQ,MAAOL,EAAW,MAAiCD,EAAWM,CAAM,CAAE,CAC3F,CAQA,SAASC,EAAYC,EAAiE,CAClF,OAAOA,EAAW,KAAK,WAAa,WACxC,CAWA,SAASH,EAAoCI,EAAcL,EAAuC,CAC9F,IAAMM,EAAgBC,EAAWP,CAAQ,EACrCQ,EACJ,OAAQF,EAAc,WAAW,KAAK,SAAU,CAC5C,IAAK,YACDE,EAAW,OACX,MACJ,IAAK,YACDA,EAAW,OACX,MACJ,IAAK,aACDA,EAAW,QACX,MACJ,IAAK,UACDA,EAAW,KACX,MACJ,IAAK,YACD,MACJ,IAAK,WACDA,EAAW,CAAC,EACZ,MACJ,QACI,MAAM,IAAI,UAAU,qBAAqBH,CAAI,EAAE,CACvD,CAKA,OAJIF,EAAYG,EAAc,UAAU,IACpCE,EAAWhB,EAAac,EAAc,UAAU,GAG/CA,EAAc,aAGZ,CACH,KAAME,EACN,QAASF,EAAc,YAC3B,EALWE,CAMf,CAQA,SAASD,EAAWE,EAA+F,CAC/G,IAAIL,EAAaK,EACXC,EAAW,GACbC,EACJ,KAAO,cAAeP,EAAW,MACzB,iBAAkBA,EAAW,OAC7BO,EAAeP,EAAW,KAAK,aAAa,GAEhDA,EAAaA,EAAW,KAAK,UAEjC,MAAO,CAAE,WAAAA,EAAY,SAAAM,EAAU,aAAAC,CAAa,CAChD","names":["index_exports","__export","createSchema","__toCommonJS","Mongoose","zodObject","modelName","connection","convertedShape","key","zodField","convertField","schema","isZodObject","definition","type","unwrappedData","unwrapType","coreType","data","optional","defaultValue"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSchema } from './_tsup-dts-rollup.cjs';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSchema } from './_tsup-dts-rollup.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirite/zod-to-mongoose",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Package for creating mongoose schemas out of Zod schemas for type safety, and removing duplicate effort.",
|
|
5
5
|
"types": "./dist/_tsup-dts-rollup.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsup",
|
|
36
|
+
"check": "tsc --noEmit",
|
|
36
37
|
"test": "vitest --run --coverage",
|
|
37
38
|
"test:watch": "vitest --ui --coverage",
|
|
38
39
|
"lint": "eslint --fix",
|
|
@@ -40,20 +41,20 @@
|
|
|
40
41
|
"release": "yarn build && npm publish"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@microsoft/api-extractor": "^7.
|
|
44
|
-
"@mirite/eslint-config-mirite": "^0.
|
|
45
|
-
"@vitest/coverage-v8": "^2.
|
|
46
|
-
"@vitest/ui": "^2.
|
|
47
|
-
"eslint": "^9.
|
|
48
|
-
"prettier": "^3.
|
|
44
|
+
"@microsoft/api-extractor": "^7.48.1",
|
|
45
|
+
"@mirite/eslint-config-mirite": "^0.1.1",
|
|
46
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
47
|
+
"@vitest/ui": "^2.1.8",
|
|
48
|
+
"eslint": "^9.17.0",
|
|
49
|
+
"prettier": "^3.4.2",
|
|
49
50
|
"prettier-plugin-jsdoc": "^1.3.0",
|
|
50
|
-
"tsup": "^8.
|
|
51
|
-
"typescript": "^5.
|
|
52
|
-
"vitest": "^2.
|
|
51
|
+
"tsup": "^8.3.5",
|
|
52
|
+
"typescript": "^5.7.2",
|
|
53
|
+
"vitest": "^2.1.8"
|
|
53
54
|
},
|
|
54
|
-
"packageManager": "yarn@4.
|
|
55
|
+
"packageManager": "yarn@4.6.0",
|
|
55
56
|
"dependencies": {
|
|
56
|
-
"mongoose": "^8.
|
|
57
|
-
"zod": "^3.
|
|
57
|
+
"mongoose": "^8.9.3",
|
|
58
|
+
"zod": "^3.24.1"
|
|
58
59
|
}
|
|
59
60
|
}
|
package/readme.md
CHANGED
|
@@ -61,11 +61,11 @@ const result = await model.create({
|
|
|
61
61
|
|
|
62
62
|
Only a subset of Zod types are supported. The following types are supported:
|
|
63
63
|
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
64
|
+
- `z.string()`
|
|
65
|
+
- `z.number()`
|
|
66
|
+
- `z.boolean()`
|
|
67
|
+
- `z.date()`
|
|
68
|
+
- `z.object()` (Nested objects are supported)
|
|
69
|
+
- `z.union()` (Type safety is not guaranteed)
|
|
70
70
|
|
|
71
71
|
Another major caveat is that no additional validation is performed on the Mongoose schema. It is recommended to use Zod for validation before saving to the database, as well as on retrieval if there are data integrity concerns.
|
package/dist/src/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createSchema } from '../_tsup-dts-rollup';
|
package/dist/src/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createSchema } from '../_tsup-dts-rollup';
|