@kikiutils/mongoose 2.1.6 → 2.1.8
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/README.md +3 -3
- package/dist/plugins/normalize.cjs +5 -5
- package/dist/plugins/normalize.cjs.map +1 -1
- package/dist/plugins/normalize.mjs +5 -5
- package/dist/plugins/normalize.mjs.map +1 -1
- package/dist/schema-builders/decimal128.cjs +1 -1
- package/dist/schema-builders/decimal128.cjs.map +1 -1
- package/dist/schema-builders/decimal128.d.ts +1 -1
- package/dist/schema-builders/decimal128.d.ts.map +1 -1
- package/dist/schema-builders/decimal128.mjs +1 -1
- package/dist/schema-builders/decimal128.mjs.map +1 -1
- package/dist/schema-builders/string.cjs +4 -4
- package/dist/schema-builders/string.cjs.map +1 -1
- package/dist/schema-builders/string.d.ts +5 -5
- package/dist/schema-builders/string.mjs +4 -4
- package/dist/schema-builders/string.mjs.map +1 -1
- package/package.json +12 -12
- package/src/plugins/normalize.ts +4 -4
- package/src/schema-builders/decimal128.ts +2 -2
- package/src/schema-builders/string.ts +7 -7
package/README.md
CHANGED
|
@@ -51,8 +51,8 @@ Please refer to the [examples](./examples/README.md) folder for usage instructio
|
|
|
51
51
|
[npm-downloads-href]: https://npmjs.com/package/@kikiutils/mongoose
|
|
52
52
|
[npm-downloads-src]: https://img.shields.io/npm/dm/@kikiutils/mongoose.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
53
53
|
|
|
54
|
-
[codecov-href]: https://codecov.io/github/
|
|
55
|
-
[codecov-src]: https://codecov.io/github/
|
|
54
|
+
[codecov-href]: https://codecov.io/github/kikiutils/node-mongoose
|
|
55
|
+
[codecov-src]: https://codecov.io/github/kikiutils/node-mongoose/graph/badge.svg?token=GRSQ7JO39E
|
|
56
56
|
|
|
57
|
-
[license-href]: https://github.com/
|
|
57
|
+
[license-href]: https://github.com/kikiutils/node-mongoose/blob/main/LICENSE
|
|
58
58
|
[license-src]: https://img.shields.io/npm/l/@kikiutils/mongoose.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
@@ -24,10 +24,10 @@ const { get: lodashGet, set: lodashSet, unset: lodashUnset, } = lodash__default;
|
|
|
24
24
|
* @param schema - The Mongoose schema to apply the plugin to.
|
|
25
25
|
*/
|
|
26
26
|
function mongooseNormalizePlugin(schema) {
|
|
27
|
-
const
|
|
28
|
-
const
|
|
27
|
+
const toJson = schema.get('toJSON');
|
|
28
|
+
const toJsonTransform = toJson?.transform;
|
|
29
29
|
schema.set('toJSON', {
|
|
30
|
-
...
|
|
30
|
+
...toJson,
|
|
31
31
|
transform(doc, ret, options) {
|
|
32
32
|
const copiedRet = { ...ret };
|
|
33
33
|
copiedRet.id = copiedRet._id?.toHexString();
|
|
@@ -42,8 +42,8 @@ function mongooseNormalizePlugin(schema) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
delete copiedRet.__v;
|
|
45
|
-
if (
|
|
46
|
-
return
|
|
45
|
+
if (toJsonTransform && typeof toJsonTransform !== 'boolean')
|
|
46
|
+
return toJsonTransform(doc, copiedRet, options);
|
|
47
47
|
return copiedRet;
|
|
48
48
|
},
|
|
49
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.cjs","sources":["../../src/plugins/normalize.ts"],"sourcesContent":["import lodash from 'lodash';\nimport type {\n Schema,\n Types,\n} from 'mongoose';\n\nconst {\n get: lodashGet,\n set: lodashSet,\n unset: lodashUnset,\n} = lodash;\n\n/**\n * Mongoose plugin to normalize the JSON output of documents.\n *\n * This plugin modifies the `toJSON` method of Mongoose schemas to:\n * - Add an `id` field equal to the string representation of `_id`\n * - Remove the `_id` field\n * - Exclude fields marked as `private` from the JSON output\n * - Convert `Decimal128` fields to strings\n * - Remove the `__v` version key\n *\n * @template S - The type of the schema.\n *\n * @param schema - The Mongoose schema to apply the plugin to.\n */\nexport function mongooseNormalizePlugin<S extends Schema>(schema: S) {\n const
|
|
1
|
+
{"version":3,"file":"normalize.cjs","sources":["../../src/plugins/normalize.ts"],"sourcesContent":["import lodash from 'lodash';\nimport type {\n Schema,\n Types,\n} from 'mongoose';\n\nconst {\n get: lodashGet,\n set: lodashSet,\n unset: lodashUnset,\n} = lodash;\n\n/**\n * Mongoose plugin to normalize the JSON output of documents.\n *\n * This plugin modifies the `toJSON` method of Mongoose schemas to:\n * - Add an `id` field equal to the string representation of `_id`\n * - Remove the `_id` field\n * - Exclude fields marked as `private` from the JSON output\n * - Convert `Decimal128` fields to strings\n * - Remove the `__v` version key\n *\n * @template S - The type of the schema.\n *\n * @param schema - The Mongoose schema to apply the plugin to.\n */\nexport function mongooseNormalizePlugin<S extends Schema>(schema: S) {\n const toJson = schema.get('toJSON');\n const toJsonTransform = toJson?.transform;\n schema.set(\n 'toJSON',\n {\n ...toJson,\n transform(doc: any, ret: any, options: any) {\n const copiedRet = { ...ret };\n copiedRet.id = copiedRet._id?.toHexString();\n delete copiedRet._id;\n for (const path in schema.paths) {\n if (schema.paths[path]?.options?.private) lodashUnset(copiedRet, path);\n if (schema.paths[path]?.instance === 'Decimal128') {\n const value: Types.Decimal128 | undefined = lodashGet(copiedRet, path);\n if (value) lodashSet(copiedRet, path, value.toString());\n }\n }\n\n delete copiedRet.__v;\n if (toJsonTransform && typeof toJsonTransform !== 'boolean') return toJsonTransform(doc, copiedRet, options);\n return copiedRet;\n },\n },\n );\n}\n\nexport default mongooseNormalizePlugin;\n"],"names":["lodash"],"mappings":";;;;;;;;;;AAMA,MAAM,EACF,GAAG,EAAE,SAAS,EACd,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,WAAW,GACrB,GAAGA,eAAM;AAEV;;;;;;;;;;;;;AAaG;AACG,SAAU,uBAAuB,CAAmB,MAAS,EAAA;IAC/D,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;AACnC,IAAA,MAAM,eAAe,GAAG,MAAM,EAAE,SAAS;AACzC,IAAA,MAAM,CAAC,GAAG,CACN,QAAQ,EACR;AACI,QAAA,GAAG,MAAM;AACT,QAAA,SAAS,CAAC,GAAQ,EAAE,GAAQ,EAAE,OAAY,EAAA;AACtC,YAAA,MAAM,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE;YAC5B,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE;YAC3C,OAAO,SAAS,CAAC,GAAG;AACpB,YAAA,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE;gBAC7B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO;AAAE,oBAAA,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC;gBACtE,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,KAAK,YAAY,EAAE;oBAC/C,MAAM,KAAK,GAAiC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC;AACtE,oBAAA,IAAI,KAAK;wBAAE,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;;;YAI/D,OAAO,SAAS,CAAC,GAAG;AACpB,YAAA,IAAI,eAAe,IAAI,OAAO,eAAe,KAAK,SAAS;gBAAE,OAAO,eAAe,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC;AAC5G,YAAA,OAAO,SAAS;SACnB;AACJ,KAAA,CACJ;AACL;;;;;"}
|
|
@@ -16,10 +16,10 @@ const { get: lodashGet, set: lodashSet, unset: lodashUnset, } = lodash;
|
|
|
16
16
|
* @param schema - The Mongoose schema to apply the plugin to.
|
|
17
17
|
*/
|
|
18
18
|
function mongooseNormalizePlugin(schema) {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
19
|
+
const toJson = schema.get('toJSON');
|
|
20
|
+
const toJsonTransform = toJson?.transform;
|
|
21
21
|
schema.set('toJSON', {
|
|
22
|
-
...
|
|
22
|
+
...toJson,
|
|
23
23
|
transform(doc, ret, options) {
|
|
24
24
|
const copiedRet = { ...ret };
|
|
25
25
|
copiedRet.id = copiedRet._id?.toHexString();
|
|
@@ -34,8 +34,8 @@ function mongooseNormalizePlugin(schema) {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
delete copiedRet.__v;
|
|
37
|
-
if (
|
|
38
|
-
return
|
|
37
|
+
if (toJsonTransform && typeof toJsonTransform !== 'boolean')
|
|
38
|
+
return toJsonTransform(doc, copiedRet, options);
|
|
39
39
|
return copiedRet;
|
|
40
40
|
},
|
|
41
41
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.mjs","sources":["../../src/plugins/normalize.ts"],"sourcesContent":["import lodash from 'lodash';\nimport type {\n Schema,\n Types,\n} from 'mongoose';\n\nconst {\n get: lodashGet,\n set: lodashSet,\n unset: lodashUnset,\n} = lodash;\n\n/**\n * Mongoose plugin to normalize the JSON output of documents.\n *\n * This plugin modifies the `toJSON` method of Mongoose schemas to:\n * - Add an `id` field equal to the string representation of `_id`\n * - Remove the `_id` field\n * - Exclude fields marked as `private` from the JSON output\n * - Convert `Decimal128` fields to strings\n * - Remove the `__v` version key\n *\n * @template S - The type of the schema.\n *\n * @param schema - The Mongoose schema to apply the plugin to.\n */\nexport function mongooseNormalizePlugin<S extends Schema>(schema: S) {\n const
|
|
1
|
+
{"version":3,"file":"normalize.mjs","sources":["../../src/plugins/normalize.ts"],"sourcesContent":["import lodash from 'lodash';\nimport type {\n Schema,\n Types,\n} from 'mongoose';\n\nconst {\n get: lodashGet,\n set: lodashSet,\n unset: lodashUnset,\n} = lodash;\n\n/**\n * Mongoose plugin to normalize the JSON output of documents.\n *\n * This plugin modifies the `toJSON` method of Mongoose schemas to:\n * - Add an `id` field equal to the string representation of `_id`\n * - Remove the `_id` field\n * - Exclude fields marked as `private` from the JSON output\n * - Convert `Decimal128` fields to strings\n * - Remove the `__v` version key\n *\n * @template S - The type of the schema.\n *\n * @param schema - The Mongoose schema to apply the plugin to.\n */\nexport function mongooseNormalizePlugin<S extends Schema>(schema: S) {\n const toJson = schema.get('toJSON');\n const toJsonTransform = toJson?.transform;\n schema.set(\n 'toJSON',\n {\n ...toJson,\n transform(doc: any, ret: any, options: any) {\n const copiedRet = { ...ret };\n copiedRet.id = copiedRet._id?.toHexString();\n delete copiedRet._id;\n for (const path in schema.paths) {\n if (schema.paths[path]?.options?.private) lodashUnset(copiedRet, path);\n if (schema.paths[path]?.instance === 'Decimal128') {\n const value: Types.Decimal128 | undefined = lodashGet(copiedRet, path);\n if (value) lodashSet(copiedRet, path, value.toString());\n }\n }\n\n delete copiedRet.__v;\n if (toJsonTransform && typeof toJsonTransform !== 'boolean') return toJsonTransform(doc, copiedRet, options);\n return copiedRet;\n },\n },\n );\n}\n\nexport default mongooseNormalizePlugin;\n"],"names":[],"mappings":";;AAMA,MAAM,EACF,GAAG,EAAE,SAAS,EACd,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,WAAW,GACrB,GAAG,MAAM;AAEV;;;;;;;;;;;;;AAaG;AACG,SAAU,uBAAuB,CAAmB,MAAS,EAAA;IAC/D,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;AACnC,IAAA,MAAM,eAAe,GAAG,MAAM,EAAE,SAAS;AACzC,IAAA,MAAM,CAAC,GAAG,CACN,QAAQ,EACR;AACI,QAAA,GAAG,MAAM;AACT,QAAA,SAAS,CAAC,GAAQ,EAAE,GAAQ,EAAE,OAAY,EAAA;AACtC,YAAA,MAAM,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE;YAC5B,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE;YAC3C,OAAO,SAAS,CAAC,GAAG;AACpB,YAAA,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE;gBAC7B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO;AAAE,oBAAA,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC;gBACtE,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,KAAK,YAAY,EAAE;oBAC/C,MAAM,KAAK,GAAiC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC;AACtE,oBAAA,IAAI,KAAK;wBAAE,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;;;YAI/D,OAAO,SAAS,CAAC,GAAG;AACpB,YAAA,IAAI,eAAe,IAAI,OAAO,eAAe,KAAK,SAAS;gBAAE,OAAO,eAAe,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC;AAC5G,YAAA,OAAO,SAAS;SACnB;AACJ,KAAA,CACJ;AACL;;;;"}
|
|
@@ -16,7 +16,7 @@ function decimal128SchemaBuilder() {
|
|
|
16
16
|
get(target, key, receiver) {
|
|
17
17
|
if (key === 'setRoundAndToFixedSetter') {
|
|
18
18
|
return (places = 2, rounding = Decimal__default.ROUND_DOWN) => {
|
|
19
|
-
schema.set = (value) => new Decimal__default(value.toString()).toFixed(places, rounding);
|
|
19
|
+
schema.set = (value) => value === undefined ? undefined : new Decimal__default(value.toString()).toFixed(places, rounding);
|
|
20
20
|
return receiver;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal128.cjs","sources":["../../src/schema-builders/decimal128.ts"],"sourcesContent":["import Decimal from 'decimal.js';\nimport { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/utils';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\nexport type ExtendDecimal128SchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<Decimal128SchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;\n\ninterface BaseProps {\n type: typeof Schema.Types.Decimal128;\n}\n\ninterface ToStringGetterSchema {\n get: (value?: Types.Decimal128) => string | undefined;\n}\n\ninterface ToStringSetterSchema {\n set: (value
|
|
1
|
+
{"version":3,"file":"decimal128.cjs","sources":["../../src/schema-builders/decimal128.ts"],"sourcesContent":["import Decimal from 'decimal.js';\nimport { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/utils';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\nexport type ExtendDecimal128SchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<Decimal128SchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;\n\ninterface BaseProps {\n type: typeof Schema.Types.Decimal128;\n}\n\ninterface ToStringGetterSchema {\n get: (value?: Types.Decimal128) => string | undefined;\n}\n\ninterface ToStringSetterSchema {\n set: (value?: { toString: () => string }) => string;\n}\n\nexport interface Decimal128SchemaBuilder<Props extends { type: typeof Schema.Types.Decimal128 } = { type: typeof Schema.Types.Decimal128 }, ExtraOmitFields extends string = never> {\n default: <T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null, D extends Types.Decimal128>(value: T) => ExtendDecimal128SchemaBuilder<Merge<Props, { default: T }>, ExtraOmitFields>;\n enum: <\n T extends\n | Readonlyable<Array<D | null>>\n | { [path: string]: D | null }\n | { message?: M; values: Readonlyable<Array<D | null>> },\n D extends Types.Decimal128,\n M extends string,\n >(\n value: T\n ) => ExtendDecimal128SchemaBuilder<Merge<Props, { enum: T }>, ExtraOmitFields>;\n\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendDecimal128SchemaBuilder<Merge<Props, { index: T }>, ExtraOmitFields>;\n nonRequired: Props;\n private: ExtendDecimal128SchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n\n /**\n * Sets the rounding and toFixed behavior for Decimal128 fields.\n * This method allows specifying the number of decimal places and the rounding strategy to be used when\n * saving the field to the database.\n *\n * @param places - The number of decimal places to round to (default is 2).\n * @param rounding - The rounding strategy from the Decimal.js library (default is Decimal.ROUND_DOWN).\n *\n * @returns A schema builder with the rounding and toFixed behavior applied to the `set` option in Mongoose.\n */\n setRoundAndToFixedSetter: (places?: number, rounding?: Decimal.Rounding) => ExtendDecimal128SchemaBuilder<Merge<Props, ToStringSetterSchema>, 'setRoundAndToFixedSetter' | ExtraOmitFields>;\n\n /**\n * Sets the toString behavior for Decimal128 fields.\n * This method defines how the Decimal128 field should be converted to a string when processing or\n * retrieving the value in the application (e.g., via getters), while still storing the value as Decimal128\n * in the database.\n *\n * @returns A schema builder with the custom `get` behavior applied to convert the Decimal128 field to a string\n * when accessed in the application.\n */\n setToStringGetter: ExtendDecimal128SchemaBuilder<Merge<Props, ToStringGetterSchema>, 'setToStringGetter' | ExtraOmitFields>;\n sparse: ExtendDecimal128SchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendDecimal128SchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Decimal128);\n\nexport function decimal128SchemaBuilder() {\n const schema: Record<string, any> = {};\n const baseBuilder = baseBuilderFactory(schema);\n return new Proxy(\n baseBuilder,\n {\n get(target, key, receiver) {\n if (key === 'setRoundAndToFixedSetter') {\n return (places: number = 2, rounding: Decimal.Rounding = Decimal.ROUND_DOWN) => {\n schema.set = (value?: { toString: () => string }) => value === undefined ? undefined : new Decimal(value.toString()).toFixed(places, rounding);\n return receiver;\n };\n }\n\n if (key === 'setToStringGetter') {\n schema.get = (value?: Types.Decimal128) => value?.toString();\n return receiver;\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as Decimal128SchemaBuilder;\n}\n"],"names":["createBaseSchemaBuilderFactory","Schema","Decimal"],"mappings":";;;;;;;;;;AAwEA,MAAM,kBAAkB,GAAGA,mC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DOWN) => {
|
|
13
|
-
schema.set = (value) => new Decimal(value.toString()).toFixed(places, rounding);
|
|
13
|
+
schema.set = (value) => value === undefined ? undefined : new Decimal(value.toString()).toFixed(places, rounding);
|
|
14
14
|
return receiver;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal128.mjs","sources":["../../src/schema-builders/decimal128.ts"],"sourcesContent":["import Decimal from 'decimal.js';\nimport { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/utils';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\nexport type ExtendDecimal128SchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<Decimal128SchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;\n\ninterface BaseProps {\n type: typeof Schema.Types.Decimal128;\n}\n\ninterface ToStringGetterSchema {\n get: (value?: Types.Decimal128) => string | undefined;\n}\n\ninterface ToStringSetterSchema {\n set: (value
|
|
1
|
+
{"version":3,"file":"decimal128.mjs","sources":["../../src/schema-builders/decimal128.ts"],"sourcesContent":["import Decimal from 'decimal.js';\nimport { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/utils';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\nexport type ExtendDecimal128SchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<Decimal128SchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;\n\ninterface BaseProps {\n type: typeof Schema.Types.Decimal128;\n}\n\ninterface ToStringGetterSchema {\n get: (value?: Types.Decimal128) => string | undefined;\n}\n\ninterface ToStringSetterSchema {\n set: (value?: { toString: () => string }) => string;\n}\n\nexport interface Decimal128SchemaBuilder<Props extends { type: typeof Schema.Types.Decimal128 } = { type: typeof Schema.Types.Decimal128 }, ExtraOmitFields extends string = never> {\n default: <T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null, D extends Types.Decimal128>(value: T) => ExtendDecimal128SchemaBuilder<Merge<Props, { default: T }>, ExtraOmitFields>;\n enum: <\n T extends\n | Readonlyable<Array<D | null>>\n | { [path: string]: D | null }\n | { message?: M; values: Readonlyable<Array<D | null>> },\n D extends Types.Decimal128,\n M extends string,\n >(\n value: T\n ) => ExtendDecimal128SchemaBuilder<Merge<Props, { enum: T }>, ExtraOmitFields>;\n\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendDecimal128SchemaBuilder<Merge<Props, { index: T }>, ExtraOmitFields>;\n nonRequired: Props;\n private: ExtendDecimal128SchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n\n /**\n * Sets the rounding and toFixed behavior for Decimal128 fields.\n * This method allows specifying the number of decimal places and the rounding strategy to be used when\n * saving the field to the database.\n *\n * @param places - The number of decimal places to round to (default is 2).\n * @param rounding - The rounding strategy from the Decimal.js library (default is Decimal.ROUND_DOWN).\n *\n * @returns A schema builder with the rounding and toFixed behavior applied to the `set` option in Mongoose.\n */\n setRoundAndToFixedSetter: (places?: number, rounding?: Decimal.Rounding) => ExtendDecimal128SchemaBuilder<Merge<Props, ToStringSetterSchema>, 'setRoundAndToFixedSetter' | ExtraOmitFields>;\n\n /**\n * Sets the toString behavior for Decimal128 fields.\n * This method defines how the Decimal128 field should be converted to a string when processing or\n * retrieving the value in the application (e.g., via getters), while still storing the value as Decimal128\n * in the database.\n *\n * @returns A schema builder with the custom `get` behavior applied to convert the Decimal128 field to a string\n * when accessed in the application.\n */\n setToStringGetter: ExtendDecimal128SchemaBuilder<Merge<Props, ToStringGetterSchema>, 'setToStringGetter' | ExtraOmitFields>;\n sparse: ExtendDecimal128SchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendDecimal128SchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Decimal128);\n\nexport function decimal128SchemaBuilder() {\n const schema: Record<string, any> = {};\n const baseBuilder = baseBuilderFactory(schema);\n return new Proxy(\n baseBuilder,\n {\n get(target, key, receiver) {\n if (key === 'setRoundAndToFixedSetter') {\n return (places: number = 2, rounding: Decimal.Rounding = Decimal.ROUND_DOWN) => {\n schema.set = (value?: { toString: () => string }) => value === undefined ? undefined : new Decimal(value.toString()).toFixed(places, rounding);\n return receiver;\n };\n }\n\n if (key === 'setToStringGetter') {\n schema.get = (value?: Types.Decimal128) => value?.toString();\n return receiver;\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as Decimal128SchemaBuilder;\n}\n"],"names":[],"mappings":";;;;AAwEA,MAAM,kBAAkB,GAAG,8BAA8B,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;SAElE,uBAAuB,GAAA;IACnC,MAAM,MAAM,GAAwB,EAAE;AACtC,IAAA,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC;AAC9C,IAAA,OAAO,IAAI,KAAK,CACZ,WAAW,EACX;AACI,QAAA,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAA;AACrB,YAAA,IAAI,GAAG,KAAK,0BAA0B,EAAE;gBACpC,OAAO,CAAC,SAAiB,CAAC,EAAE,WAA6B,OAAO,CAAC,UAAU,KAAI;AAC3E,oBAAA,MAAM,CAAC,GAAG,GAAG,CAAC,KAAkC,KAAK,KAAK,KAAK,SAAS,GAAG,SAAS,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC;AAC9I,oBAAA,OAAO,QAAQ;AACnB,iBAAC;;AAGL,YAAA,IAAI,GAAG,KAAK,mBAAmB,EAAE;AAC7B,gBAAA,MAAM,CAAC,GAAG,GAAG,CAAC,KAAwB,KAAK,KAAK,EAAE,QAAQ,EAAE;AAC5D,gBAAA,OAAO,QAAQ;;YAGnB,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC;SAC5C;AACJ,KAAA,CACuB;AAChC;;;;"}
|
|
@@ -8,15 +8,15 @@ const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e
|
|
|
8
8
|
const net__default = /*#__PURE__*/_interopDefaultCompat(net);
|
|
9
9
|
|
|
10
10
|
const baseBuilderFactory = base.createBaseSchemaBuilderFactory(String);
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const defaultIpv4ValidateMessage = '`{VALUE}` is not a valid IPv4 address for path `{PATH}`.';
|
|
12
|
+
const defaultIpv6ValidateMessage = '`{VALUE}` is not a valid IPv6 address for path `{PATH}`.';
|
|
13
13
|
function stringSchemaBuilder() {
|
|
14
14
|
const schema = {};
|
|
15
15
|
const baseBuilder = baseBuilderFactory(schema);
|
|
16
16
|
return new Proxy(baseBuilder, {
|
|
17
17
|
get(target, key, receiver) {
|
|
18
18
|
if (key === 'ipv4') {
|
|
19
|
-
return (message =
|
|
19
|
+
return (message = defaultIpv4ValidateMessage) => {
|
|
20
20
|
schema.trim = true;
|
|
21
21
|
schema.validate = {
|
|
22
22
|
message,
|
|
@@ -26,7 +26,7 @@ function stringSchemaBuilder() {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
if (key === 'ipv6') {
|
|
29
|
-
return (message =
|
|
29
|
+
return (message = defaultIpv6ValidateMessage) => {
|
|
30
30
|
schema.trim = true;
|
|
31
31
|
schema.validate = {
|
|
32
32
|
message,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.cjs","sources":["../../src/schema-builders/string.ts"],"sourcesContent":["import type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n StringSchemaDefinition,\n} from 'mongoose';\nimport net from 'node:net';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/utils';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\nexport type ExtendStringSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<StringSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;\n\ninterface BaseProps {\n type: StringSchemaDefinition;\n}\n\ninterface
|
|
1
|
+
{"version":3,"file":"string.cjs","sources":["../../src/schema-builders/string.ts"],"sourcesContent":["import type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n StringSchemaDefinition,\n} from 'mongoose';\nimport net from 'node:net';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/utils';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\nexport type ExtendStringSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<StringSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;\n\ninterface BaseProps {\n type: StringSchemaDefinition;\n}\n\ninterface IpSchema<T extends string> {\n trim: true;\n validate: { message: T; validator: (value: string) => boolean };\n}\n\nexport interface StringSchemaBuilder<Props extends { type: StringSchemaDefinition } = { type: StringSchemaDefinition }, ExtraOmitFields extends string = never> {\n default: <T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null, D extends string>(value: T) => ExtendStringSchemaBuilder<Merge<Props, { default: T }>, ExtraOmitFields>;\n enum: <\n T extends\n | Readonlyable<Array<null | S>>\n | { [path: string]: null | S }\n | { message?: M; values: Readonlyable<Array<null | S>> },\n M extends string,\n S extends string,\n >(\n value: T\n ) => ExtendStringSchemaBuilder<Merge<Props, { enum: T }>, ExtraOmitFields>;\n\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendStringSchemaBuilder<Merge<Props, { index: T }>, ExtraOmitFields>;\n\n /**\n * Adds IPv4 validation to the string schema.\n * Ensures the string is a valid IPv4 address and trims the input. The validation message can be customized.\n *\n * @param message - The custom error message to return if validation fails. Defaults to a standard IPv4 validation message.\n *\n * @returns A schema builder with IPv4 validation and the `trim` option enabled.\n */\n ipv4: <T extends string = typeof defaultIpv4ValidateMessage>(message?: T) => ExtendStringSchemaBuilder<Merge<Props, IpSchema<T>>, 'ipv4' | 'ipv6' | ExtraOmitFields>;\n\n /**\n * Adds IPv6 validation to the string schema.\n * Ensures the string is a valid IPv6 address and trims the input. The validation message can be customized.\n *\n * @param message - The custom error message to return if validation fails. Defaults to a standard IPv6 validation message.\n *\n * @returns A schema builder with IPv6 validation and the `trim` option enabled.\n */\n ipv6: <T extends string = typeof defaultIpv6ValidateMessage>(message?: T) => ExtendStringSchemaBuilder<Merge<Props, IpSchema<T>>, 'ipv4' | 'ipv6' | ExtraOmitFields>;\n\n /**\n * Sets both the maximum and minimum length of the string.\n * This method ensures the string length is exactly or within a specified range.\n *\n * @param value - A number representing the exact length or an array specifying [minimum, maximum] length.\n *\n * @returns A schema builder with both `maxlength` and `minlength` options applied.\n */\n length: <T extends L | Readonlyable<[L, S]>, L extends number, S extends string>(value: T) => ExtendStringSchemaBuilder<Merge<Props, { maxlength: T; minlength: T }>, ExtraOmitFields>;\n lowercase: ExtendStringSchemaBuilder<Merge<Props, { lowercase: true }>, ExtraOmitFields>;\n maxlength: <T extends L | Readonlyable<[L, S]>, L extends number, S extends string>(value: T) => ExtendStringSchemaBuilder<Merge<Props, { maxlength: T }>, ExtraOmitFields>;\n minlength: <T extends L | Readonlyable<[L, S]>, L extends number, S extends string>(value: T) => ExtendStringSchemaBuilder<Merge<Props, { minlength: T }>, ExtraOmitFields>;\n nonRequired: Props;\n private: ExtendStringSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendStringSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n text: ExtendStringSchemaBuilder<Merge<Props, { text: true }>, ExtraOmitFields>;\n trim: ExtendStringSchemaBuilder<Merge<Props, { trim: true }>, ExtraOmitFields>;\n unique: ExtendStringSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n uppercase: ExtendStringSchemaBuilder<Merge<Props, { uppercase: true }>, ExtraOmitFields>;\n}\n\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(String);\nconst defaultIpv4ValidateMessage = '`{VALUE}` is not a valid IPv4 address for path `{PATH}`.';\nconst defaultIpv6ValidateMessage = '`{VALUE}` is not a valid IPv6 address for path `{PATH}`.';\n\nexport function stringSchemaBuilder() {\n const schema: Record<string, any> = {};\n const baseBuilder = baseBuilderFactory(schema);\n return new Proxy(\n baseBuilder,\n {\n get(target, key, receiver) {\n if (key === 'ipv4') {\n return (message: string = defaultIpv4ValidateMessage) => {\n schema.trim = true;\n schema.validate = {\n message,\n validator: (value: string) => net.isIPv4(value),\n };\n\n return receiver;\n };\n }\n\n if (key === 'ipv6') {\n return (message: string = defaultIpv6ValidateMessage) => {\n schema.trim = true;\n schema.validate = {\n message,\n validator: (value: string) => net.isIPv6(value),\n };\n\n return receiver;\n };\n }\n\n if (key === 'length') {\n return (value: any) => {\n schema.maxlength = schema.minlength = value;\n return receiver;\n };\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as StringSchemaBuilder;\n}\n"],"names":["createBaseSchemaBuilderFactory","net"],"mappings":";;;;;;;;;AAiFA,MAAM,kBAAkB,GAAGA,mCAA8B,CAAC,MAAM,CAAC;AACjE,MAAM,0BAA0B,GAAG,0DAA0D;AAC7F,MAAM,0BAA0B,GAAG,0DAA0D;SAE7E,mBAAmB,GAAA;IAC/B,MAAM,MAAM,GAAwB,EAAE;AACtC,IAAA,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC;AAC9C,IAAA,OAAO,IAAI,KAAK,CACZ,WAAW,EACX;AACI,QAAA,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAA;AACrB,YAAA,IAAI,GAAG,KAAK,MAAM,EAAE;AAChB,gBAAA,OAAO,CAAC,OAAA,GAAkB,0BAA0B,KAAI;AACpD,oBAAA,MAAM,CAAC,IAAI,GAAG,IAAI;oBAClB,MAAM,CAAC,QAAQ,GAAG;wBACd,OAAO;wBACP,SAAS,EAAE,CAAC,KAAa,KAAKC,YAAG,CAAC,MAAM,CAAC,KAAK,CAAC;qBAClD;AAED,oBAAA,OAAO,QAAQ;AACnB,iBAAC;;AAGL,YAAA,IAAI,GAAG,KAAK,MAAM,EAAE;AAChB,gBAAA,OAAO,CAAC,OAAA,GAAkB,0BAA0B,KAAI;AACpD,oBAAA,MAAM,CAAC,IAAI,GAAG,IAAI;oBAClB,MAAM,CAAC,QAAQ,GAAG;wBACd,OAAO;wBACP,SAAS,EAAE,CAAC,KAAa,KAAKA,YAAG,CAAC,MAAM,CAAC,KAAK,CAAC;qBAClD;AAED,oBAAA,OAAO,QAAQ;AACnB,iBAAC;;AAGL,YAAA,IAAI,GAAG,KAAK,QAAQ,EAAE;gBAClB,OAAO,CAAC,KAAU,KAAI;oBAClB,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,GAAG,KAAK;AAC3C,oBAAA,OAAO,QAAQ;AACnB,iBAAC;;YAGL,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC;SAC5C;AACJ,KAAA,CACmB;AAC5B;;;;"}
|
|
@@ -5,7 +5,7 @@ export type ExtendStringSchemaBuilder<Props extends BaseProps, ExtraOmitFields e
|
|
|
5
5
|
interface BaseProps {
|
|
6
6
|
type: StringSchemaDefinition;
|
|
7
7
|
}
|
|
8
|
-
interface
|
|
8
|
+
interface IpSchema<T extends string> {
|
|
9
9
|
trim: true;
|
|
10
10
|
validate: {
|
|
11
11
|
message: T;
|
|
@@ -39,7 +39,7 @@ export interface StringSchemaBuilder<Props extends {
|
|
|
39
39
|
*
|
|
40
40
|
* @returns A schema builder with IPv4 validation and the `trim` option enabled.
|
|
41
41
|
*/
|
|
42
|
-
ipv4: <T extends string = typeof
|
|
42
|
+
ipv4: <T extends string = typeof defaultIpv4ValidateMessage>(message?: T) => ExtendStringSchemaBuilder<Merge<Props, IpSchema<T>>, 'ipv4' | 'ipv6' | ExtraOmitFields>;
|
|
43
43
|
/**
|
|
44
44
|
* Adds IPv6 validation to the string schema.
|
|
45
45
|
* Ensures the string is a valid IPv6 address and trims the input. The validation message can be customized.
|
|
@@ -48,7 +48,7 @@ export interface StringSchemaBuilder<Props extends {
|
|
|
48
48
|
*
|
|
49
49
|
* @returns A schema builder with IPv6 validation and the `trim` option enabled.
|
|
50
50
|
*/
|
|
51
|
-
ipv6: <T extends string = typeof
|
|
51
|
+
ipv6: <T extends string = typeof defaultIpv6ValidateMessage>(message?: T) => ExtendStringSchemaBuilder<Merge<Props, IpSchema<T>>, 'ipv4' | 'ipv6' | ExtraOmitFields>;
|
|
52
52
|
/**
|
|
53
53
|
* Sets both the maximum and minimum length of the string.
|
|
54
54
|
* This method ensures the string length is exactly or within a specified range.
|
|
@@ -93,8 +93,8 @@ export interface StringSchemaBuilder<Props extends {
|
|
|
93
93
|
uppercase: true;
|
|
94
94
|
}>, ExtraOmitFields>;
|
|
95
95
|
}
|
|
96
|
-
declare const
|
|
97
|
-
declare const
|
|
96
|
+
declare const defaultIpv4ValidateMessage = "`{VALUE}` is not a valid IPv4 address for path `{PATH}`.";
|
|
97
|
+
declare const defaultIpv6ValidateMessage = "`{VALUE}` is not a valid IPv6 address for path `{PATH}`.";
|
|
98
98
|
export declare function stringSchemaBuilder(): StringSchemaBuilder;
|
|
99
99
|
export {};
|
|
100
100
|
//# sourceMappingURL=string.d.ts.map
|
|
@@ -2,15 +2,15 @@ import net from 'node:net';
|
|
|
2
2
|
import { createBaseSchemaBuilderFactory } from './base.mjs';
|
|
3
3
|
|
|
4
4
|
const baseBuilderFactory = createBaseSchemaBuilderFactory(String);
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const defaultIpv4ValidateMessage = '`{VALUE}` is not a valid IPv4 address for path `{PATH}`.';
|
|
6
|
+
const defaultIpv6ValidateMessage = '`{VALUE}` is not a valid IPv6 address for path `{PATH}`.';
|
|
7
7
|
function stringSchemaBuilder() {
|
|
8
8
|
const schema = {};
|
|
9
9
|
const baseBuilder = baseBuilderFactory(schema);
|
|
10
10
|
return new Proxy(baseBuilder, {
|
|
11
11
|
get(target, key, receiver) {
|
|
12
12
|
if (key === 'ipv4') {
|
|
13
|
-
return (message =
|
|
13
|
+
return (message = defaultIpv4ValidateMessage) => {
|
|
14
14
|
schema.trim = true;
|
|
15
15
|
schema.validate = {
|
|
16
16
|
message,
|
|
@@ -20,7 +20,7 @@ function stringSchemaBuilder() {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
if (key === 'ipv6') {
|
|
23
|
-
return (message =
|
|
23
|
+
return (message = defaultIpv6ValidateMessage) => {
|
|
24
24
|
schema.trim = true;
|
|
25
25
|
schema.validate = {
|
|
26
26
|
message,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.mjs","sources":["../../src/schema-builders/string.ts"],"sourcesContent":["import type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n StringSchemaDefinition,\n} from 'mongoose';\nimport net from 'node:net';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/utils';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\nexport type ExtendStringSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<StringSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;\n\ninterface BaseProps {\n type: StringSchemaDefinition;\n}\n\ninterface
|
|
1
|
+
{"version":3,"file":"string.mjs","sources":["../../src/schema-builders/string.ts"],"sourcesContent":["import type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n StringSchemaDefinition,\n} from 'mongoose';\nimport net from 'node:net';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/utils';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\nexport type ExtendStringSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<StringSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;\n\ninterface BaseProps {\n type: StringSchemaDefinition;\n}\n\ninterface IpSchema<T extends string> {\n trim: true;\n validate: { message: T; validator: (value: string) => boolean };\n}\n\nexport interface StringSchemaBuilder<Props extends { type: StringSchemaDefinition } = { type: StringSchemaDefinition }, ExtraOmitFields extends string = never> {\n default: <T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null, D extends string>(value: T) => ExtendStringSchemaBuilder<Merge<Props, { default: T }>, ExtraOmitFields>;\n enum: <\n T extends\n | Readonlyable<Array<null | S>>\n | { [path: string]: null | S }\n | { message?: M; values: Readonlyable<Array<null | S>> },\n M extends string,\n S extends string,\n >(\n value: T\n ) => ExtendStringSchemaBuilder<Merge<Props, { enum: T }>, ExtraOmitFields>;\n\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendStringSchemaBuilder<Merge<Props, { index: T }>, ExtraOmitFields>;\n\n /**\n * Adds IPv4 validation to the string schema.\n * Ensures the string is a valid IPv4 address and trims the input. The validation message can be customized.\n *\n * @param message - The custom error message to return if validation fails. Defaults to a standard IPv4 validation message.\n *\n * @returns A schema builder with IPv4 validation and the `trim` option enabled.\n */\n ipv4: <T extends string = typeof defaultIpv4ValidateMessage>(message?: T) => ExtendStringSchemaBuilder<Merge<Props, IpSchema<T>>, 'ipv4' | 'ipv6' | ExtraOmitFields>;\n\n /**\n * Adds IPv6 validation to the string schema.\n * Ensures the string is a valid IPv6 address and trims the input. The validation message can be customized.\n *\n * @param message - The custom error message to return if validation fails. Defaults to a standard IPv6 validation message.\n *\n * @returns A schema builder with IPv6 validation and the `trim` option enabled.\n */\n ipv6: <T extends string = typeof defaultIpv6ValidateMessage>(message?: T) => ExtendStringSchemaBuilder<Merge<Props, IpSchema<T>>, 'ipv4' | 'ipv6' | ExtraOmitFields>;\n\n /**\n * Sets both the maximum and minimum length of the string.\n * This method ensures the string length is exactly or within a specified range.\n *\n * @param value - A number representing the exact length or an array specifying [minimum, maximum] length.\n *\n * @returns A schema builder with both `maxlength` and `minlength` options applied.\n */\n length: <T extends L | Readonlyable<[L, S]>, L extends number, S extends string>(value: T) => ExtendStringSchemaBuilder<Merge<Props, { maxlength: T; minlength: T }>, ExtraOmitFields>;\n lowercase: ExtendStringSchemaBuilder<Merge<Props, { lowercase: true }>, ExtraOmitFields>;\n maxlength: <T extends L | Readonlyable<[L, S]>, L extends number, S extends string>(value: T) => ExtendStringSchemaBuilder<Merge<Props, { maxlength: T }>, ExtraOmitFields>;\n minlength: <T extends L | Readonlyable<[L, S]>, L extends number, S extends string>(value: T) => ExtendStringSchemaBuilder<Merge<Props, { minlength: T }>, ExtraOmitFields>;\n nonRequired: Props;\n private: ExtendStringSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendStringSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n text: ExtendStringSchemaBuilder<Merge<Props, { text: true }>, ExtraOmitFields>;\n trim: ExtendStringSchemaBuilder<Merge<Props, { trim: true }>, ExtraOmitFields>;\n unique: ExtendStringSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n uppercase: ExtendStringSchemaBuilder<Merge<Props, { uppercase: true }>, ExtraOmitFields>;\n}\n\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(String);\nconst defaultIpv4ValidateMessage = '`{VALUE}` is not a valid IPv4 address for path `{PATH}`.';\nconst defaultIpv6ValidateMessage = '`{VALUE}` is not a valid IPv6 address for path `{PATH}`.';\n\nexport function stringSchemaBuilder() {\n const schema: Record<string, any> = {};\n const baseBuilder = baseBuilderFactory(schema);\n return new Proxy(\n baseBuilder,\n {\n get(target, key, receiver) {\n if (key === 'ipv4') {\n return (message: string = defaultIpv4ValidateMessage) => {\n schema.trim = true;\n schema.validate = {\n message,\n validator: (value: string) => net.isIPv4(value),\n };\n\n return receiver;\n };\n }\n\n if (key === 'ipv6') {\n return (message: string = defaultIpv6ValidateMessage) => {\n schema.trim = true;\n schema.validate = {\n message,\n validator: (value: string) => net.isIPv6(value),\n };\n\n return receiver;\n };\n }\n\n if (key === 'length') {\n return (value: any) => {\n schema.maxlength = schema.minlength = value;\n return receiver;\n };\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as StringSchemaBuilder;\n}\n"],"names":[],"mappings":";;;AAiFA,MAAM,kBAAkB,GAAG,8BAA8B,CAAC,MAAM,CAAC;AACjE,MAAM,0BAA0B,GAAG,0DAA0D;AAC7F,MAAM,0BAA0B,GAAG,0DAA0D;SAE7E,mBAAmB,GAAA;IAC/B,MAAM,MAAM,GAAwB,EAAE;AACtC,IAAA,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC;AAC9C,IAAA,OAAO,IAAI,KAAK,CACZ,WAAW,EACX;AACI,QAAA,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAA;AACrB,YAAA,IAAI,GAAG,KAAK,MAAM,EAAE;AAChB,gBAAA,OAAO,CAAC,OAAA,GAAkB,0BAA0B,KAAI;AACpD,oBAAA,MAAM,CAAC,IAAI,GAAG,IAAI;oBAClB,MAAM,CAAC,QAAQ,GAAG;wBACd,OAAO;wBACP,SAAS,EAAE,CAAC,KAAa,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;qBAClD;AAED,oBAAA,OAAO,QAAQ;AACnB,iBAAC;;AAGL,YAAA,IAAI,GAAG,KAAK,MAAM,EAAE;AAChB,gBAAA,OAAO,CAAC,OAAA,GAAkB,0BAA0B,KAAI;AACpD,oBAAA,MAAM,CAAC,IAAI,GAAG,IAAI;oBAClB,MAAM,CAAC,QAAQ,GAAG;wBACd,OAAO;wBACP,SAAS,EAAE,CAAC,KAAa,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;qBAClD;AAED,oBAAA,OAAO,QAAQ;AACnB,iBAAC;;AAGL,YAAA,IAAI,GAAG,KAAK,QAAQ,EAAE;gBAClB,OAAO,CAAC,KAAU,KAAI;oBAClB,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,GAAG,KAAK;AAC3C,oBAAA,OAAO,QAAQ;AACnB,iBAAC;;YAGL,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC;SAC5C;AACJ,KAAA,CACmB;AAC5B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kikiutils/mongoose",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.8",
|
|
4
4
|
"description": "A Mongoose plugin for enhanced JSON normalization and common schema creation, with built-in support for pagination and automatic Decimal128 conversion.",
|
|
5
5
|
"author": "kiki-kanri",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/kikiutils/node-mongoose.git"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [
|
|
12
12
|
"Decimal128",
|
|
@@ -53,27 +53,27 @@
|
|
|
53
53
|
"bumplog": "changelogen --bump",
|
|
54
54
|
"lint": "eslint",
|
|
55
55
|
"lint:fix": "eslint --fix",
|
|
56
|
-
"release": "pnpm run lint && pnpm run build && pnpm run test && changelogen --push --release && npm publish",
|
|
56
|
+
"release": "pnpm run lint && pnpm run build && pnpm run test && changelogen --hideAuthorEmail --push --release && npm publish",
|
|
57
57
|
"test": "jest --coverage"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"decimal.js": "^10.5.0",
|
|
61
61
|
"lodash": "^4.17.21",
|
|
62
|
-
"mongoose": "^8.
|
|
62
|
+
"mongoose": "^8.12.1",
|
|
63
63
|
"mongoose-aggregate-paginate-v2": "^1.1.4",
|
|
64
64
|
"mongoose-paginate-v2": "^1.9.0",
|
|
65
|
-
"type-fest": "^4.
|
|
65
|
+
"type-fest": "^4.37.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@kikiutils/changelogen": "^0.
|
|
69
|
-
"@kikiutils/eslint-config": "^0.
|
|
70
|
-
"@kikiutils/tsconfigs": "^3.0.
|
|
68
|
+
"@kikiutils/changelogen": "^0.8.0",
|
|
69
|
+
"@kikiutils/eslint-config": "^0.8.3",
|
|
70
|
+
"@kikiutils/tsconfigs": "^3.0.3",
|
|
71
71
|
"@types/jest": "^29.5.14",
|
|
72
|
-
"@types/lodash": "^4.17.
|
|
73
|
-
"@types/node": "^22.13.
|
|
72
|
+
"@types/lodash": "^4.17.16",
|
|
73
|
+
"@types/node": "^22.13.10",
|
|
74
74
|
"jest": "^29.7.0",
|
|
75
|
-
"ts-jest": "^29.2.
|
|
76
|
-
"ts-project-builder": "^3.4.
|
|
75
|
+
"ts-jest": "^29.2.6",
|
|
76
|
+
"ts-project-builder": "^3.4.1",
|
|
77
77
|
"tslib": "^2.8.1"
|
|
78
78
|
}
|
|
79
79
|
}
|
package/src/plugins/normalize.ts
CHANGED
|
@@ -25,12 +25,12 @@ const {
|
|
|
25
25
|
* @param schema - The Mongoose schema to apply the plugin to.
|
|
26
26
|
*/
|
|
27
27
|
export function mongooseNormalizePlugin<S extends Schema>(schema: S) {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
28
|
+
const toJson = schema.get('toJSON');
|
|
29
|
+
const toJsonTransform = toJson?.transform;
|
|
30
30
|
schema.set(
|
|
31
31
|
'toJSON',
|
|
32
32
|
{
|
|
33
|
-
...
|
|
33
|
+
...toJson,
|
|
34
34
|
transform(doc: any, ret: any, options: any) {
|
|
35
35
|
const copiedRet = { ...ret };
|
|
36
36
|
copiedRet.id = copiedRet._id?.toHexString();
|
|
@@ -44,7 +44,7 @@ export function mongooseNormalizePlugin<S extends Schema>(schema: S) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
delete copiedRet.__v;
|
|
47
|
-
if (
|
|
47
|
+
if (toJsonTransform && typeof toJsonTransform !== 'boolean') return toJsonTransform(doc, copiedRet, options);
|
|
48
48
|
return copiedRet;
|
|
49
49
|
},
|
|
50
50
|
},
|
|
@@ -23,7 +23,7 @@ interface ToStringGetterSchema {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
interface ToStringSetterSchema {
|
|
26
|
-
set: (value
|
|
26
|
+
set: (value?: { toString: () => string }) => string;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export interface Decimal128SchemaBuilder<Props extends { type: typeof Schema.Types.Decimal128 } = { type: typeof Schema.Types.Decimal128 }, ExtraOmitFields extends string = never> {
|
|
@@ -81,7 +81,7 @@ export function decimal128SchemaBuilder() {
|
|
|
81
81
|
get(target, key, receiver) {
|
|
82
82
|
if (key === 'setRoundAndToFixedSetter') {
|
|
83
83
|
return (places: number = 2, rounding: Decimal.Rounding = Decimal.ROUND_DOWN) => {
|
|
84
|
-
schema.set = (value
|
|
84
|
+
schema.set = (value?: { toString: () => string }) => value === undefined ? undefined : new Decimal(value.toString()).toFixed(places, rounding);
|
|
85
85
|
return receiver;
|
|
86
86
|
};
|
|
87
87
|
}
|
|
@@ -17,7 +17,7 @@ interface BaseProps {
|
|
|
17
17
|
type: StringSchemaDefinition;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
interface
|
|
20
|
+
interface IpSchema<T extends string> {
|
|
21
21
|
trim: true;
|
|
22
22
|
validate: { message: T; validator: (value: string) => boolean };
|
|
23
23
|
}
|
|
@@ -45,7 +45,7 @@ export interface StringSchemaBuilder<Props extends { type: StringSchemaDefinitio
|
|
|
45
45
|
*
|
|
46
46
|
* @returns A schema builder with IPv4 validation and the `trim` option enabled.
|
|
47
47
|
*/
|
|
48
|
-
ipv4: <T extends string = typeof
|
|
48
|
+
ipv4: <T extends string = typeof defaultIpv4ValidateMessage>(message?: T) => ExtendStringSchemaBuilder<Merge<Props, IpSchema<T>>, 'ipv4' | 'ipv6' | ExtraOmitFields>;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Adds IPv6 validation to the string schema.
|
|
@@ -55,7 +55,7 @@ export interface StringSchemaBuilder<Props extends { type: StringSchemaDefinitio
|
|
|
55
55
|
*
|
|
56
56
|
* @returns A schema builder with IPv6 validation and the `trim` option enabled.
|
|
57
57
|
*/
|
|
58
|
-
ipv6: <T extends string = typeof
|
|
58
|
+
ipv6: <T extends string = typeof defaultIpv6ValidateMessage>(message?: T) => ExtendStringSchemaBuilder<Merge<Props, IpSchema<T>>, 'ipv4' | 'ipv6' | ExtraOmitFields>;
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Sets both the maximum and minimum length of the string.
|
|
@@ -80,8 +80,8 @@ export interface StringSchemaBuilder<Props extends { type: StringSchemaDefinitio
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
const baseBuilderFactory = createBaseSchemaBuilderFactory(String);
|
|
83
|
-
const
|
|
84
|
-
const
|
|
83
|
+
const defaultIpv4ValidateMessage = '`{VALUE}` is not a valid IPv4 address for path `{PATH}`.';
|
|
84
|
+
const defaultIpv6ValidateMessage = '`{VALUE}` is not a valid IPv6 address for path `{PATH}`.';
|
|
85
85
|
|
|
86
86
|
export function stringSchemaBuilder() {
|
|
87
87
|
const schema: Record<string, any> = {};
|
|
@@ -91,7 +91,7 @@ export function stringSchemaBuilder() {
|
|
|
91
91
|
{
|
|
92
92
|
get(target, key, receiver) {
|
|
93
93
|
if (key === 'ipv4') {
|
|
94
|
-
return (message: string =
|
|
94
|
+
return (message: string = defaultIpv4ValidateMessage) => {
|
|
95
95
|
schema.trim = true;
|
|
96
96
|
schema.validate = {
|
|
97
97
|
message,
|
|
@@ -103,7 +103,7 @@ export function stringSchemaBuilder() {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
if (key === 'ipv6') {
|
|
106
|
-
return (message: string =
|
|
106
|
+
return (message: string = defaultIpv6ValidateMessage) => {
|
|
107
107
|
schema.trim = true;
|
|
108
108
|
schema.validate = {
|
|
109
109
|
message,
|