@kikiutils/mongoose 2.0.0-rc.0 → 2.0.0

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 CHANGED
@@ -11,34 +11,32 @@ A Mongoose plugin for enhanced JSON normalization and common schema creation, wi
11
11
 
12
12
  ## Features
13
13
 
14
- - ✨ Flexible Connections: Choose to use a specific connection or fall back to a default connection, with an automatic creation of a connection if none is provided
15
- - ✨ Plugin Integration: Automatically integrates `mongoose-aggregate-paginate-v2`, `mongoose-paginate-v2`, and a custom normalization plugin for enhanced JSON output
16
- - 🛠 Predefined Schemas: Provides a set of commonly used schema definitions such as boolean, decimal128, number, objectId, and string
17
- - 🛠 Customizable: Allows for custom schemas and settings, including automatic rounding and fixed decimal places for `Decimal128` fields
18
- - 🔄 Enhanced JSON Output: Adds an `id` field, removes `_id` and `__v` fields, excludes private fields, and converts `Decimal128` fields to strings in JSON output
19
- - 🧩 Reference Schema Creation: Easily create schema definitions for ObjectId references with attributes like `private`, `required`, and `unique`
20
- - 🧩 String Schema Creation: Generate string schema definitions with attributes such as `private`, `required`, `short`, `trim`, and `unique`
21
- - 🧩 Decimal128 Field Conversion: Set up getters to convert `Decimal128` fields to strings for easier handling in documents
22
- - 🧩 Document Conversion: Convert documents or ObjectIds to documents using specified models, with optional field selection
14
+ - ✨ Flexible Connections: Supports both default and custom connections, automatically creating connections when none are provided
15
+ - 🔌 Plugin Integration: Automatically integrates `mongoose-aggregate-paginate-v2`, `mongoose-paginate-v2`, and custom normalization for cleaner JSON outputs
16
+ - 🛠 Predefined & Customizable Schemas: Provides common schemas (boolean, date, decimal128, number, objectId, string) with the flexibility to customize attributes such as `private`, `required`, `unique`, `default`, and more
17
+ - 🧮 Decimal Precision: Supports `Decimal128` fields with options for automatic rounding and fixed decimal precision
18
+ - 🔄 Optimized JSON Output: Adds an `id` field, removes `_id` and `__v`, hides private fields, and converts `Decimal128` fields to strings in JSON responses
19
+ - 🔄 Reference Management: Enables easy conversion of ObjectId references to fully populated documents with field selection and population options
20
+ - 🔧 Utility Functions: Includes helper functions for converting and normalizing documents, handling ObjectId transformations, and processing schema fields
23
21
 
24
22
  ## Environment Requirements
25
23
 
26
24
  - Mongoose version 8.x
27
- - Node.js version 18 or higher
25
+ - Node.js version 18.12.1 or higher
28
26
 
29
27
  ## Installation
30
28
 
31
29
  Add dependency (example using pnpm).
32
30
 
33
31
  ```bash
34
- pnpm add @kikiutils/mongoose
32
+ pnpm add @kikiutils/mongoose mongoose
35
33
  ```
36
34
 
37
35
  You can also use yarn, npm, or bun to add the dependency.
38
36
 
39
37
  That's it! You're ready to use this package in your project. Check out the [usage instructions](#usage) below ✨.
40
38
 
41
- # Usage
39
+ ## Usage
42
40
 
43
41
  Please refer to the [examples](./examples/README.md) folder for usage instructions of this package.
44
42
 
package/constants.cjs CHANGED
@@ -1,18 +1,12 @@
1
1
  'use strict';
2
2
 
3
- const utils = require('./utils.cjs');
4
- const _connections = require('./_connections.cjs');
5
-
6
3
  /**
7
- * Common Mongoose schemas.
8
- *
9
- * This constant holds a set of commonly used Mongoose schema definitions, generated
10
- * by the `createCommonMongooseSchemas` utility function. These schemas include common
11
- * field types and configurations used across multiple models.
4
+ * Mongoose connections.
12
5
  *
13
- * @deprecated - Will be removed in the next major version. Use {@link schemaBuilders} instead.
6
+ * This constant is a record of named Mongoose connections, allowing multiple
7
+ * database connections to be managed within the application. An optional `default`
8
+ * connection can also be specified for use when a specific connection is not provided.
14
9
  */
15
- const commonMongooseSchemas = utils.createCommonMongooseSchemas();
10
+ const mongooseConnections = {};
16
11
 
17
- exports.mongooseConnections = _connections.mongooseConnections;
18
- exports.commonMongooseSchemas = commonMongooseSchemas;
12
+ exports.mongooseConnections = mongooseConnections;
package/constants.d.ts CHANGED
@@ -1,341 +1,9 @@
1
- export { mongooseConnections } from './_connections';
2
- import type { schemaBuilders } from './schema-builders';
3
- export type DoNotUseOrRemoveThisType = typeof schemaBuilders;
1
+ import type { MongooseConnections } from './types';
4
2
  /**
5
- * Common Mongoose schemas.
3
+ * Mongoose connections.
6
4
  *
7
- * This constant holds a set of commonly used Mongoose schema definitions, generated
8
- * by the `createCommonMongooseSchemas` utility function. These schemas include common
9
- * field types and configurations used across multiple models.
10
- *
11
- * @deprecated - Will be removed in the next major version. Use {@link schemaBuilders} instead.
5
+ * This constant is a record of named Mongoose connections, allowing multiple
6
+ * database connections to be managed within the application. An optional `default`
7
+ * connection can also be specified for use when a specific connection is not provided.
12
8
  */
13
- export declare const commonMongooseSchemas: {
14
- readonly boolean: {
15
- readonly defaultFalse: {
16
- readonly nonRequired: {
17
- readonly default: false;
18
- readonly type: BooleanConstructor;
19
- };
20
- readonly required: {
21
- readonly default: false;
22
- readonly required: true;
23
- readonly type: BooleanConstructor;
24
- };
25
- };
26
- readonly defaultTrue: {
27
- readonly nonRequired: {
28
- readonly default: true;
29
- readonly type: BooleanConstructor;
30
- };
31
- readonly required: {
32
- readonly default: true;
33
- readonly required: true;
34
- readonly type: BooleanConstructor;
35
- };
36
- };
37
- readonly nonRequired: {
38
- readonly type: BooleanConstructor;
39
- };
40
- readonly required: {
41
- readonly required: true;
42
- readonly type: BooleanConstructor;
43
- };
44
- };
45
- readonly decimal128: {
46
- readonly autoRoundAndToFixed: {
47
- readonly nonRequired: {
48
- readonly set: (value: string | number | {
49
- toString(): string;
50
- }) => string;
51
- readonly type: typeof import("mongoose").Schema.Types.Decimal128;
52
- };
53
- readonly required: {
54
- readonly required: true;
55
- readonly set: (value: string | number | {
56
- toString(): string;
57
- }) => string;
58
- readonly type: typeof import("mongoose").Schema.Types.Decimal128;
59
- };
60
- };
61
- readonly nonRequired: {
62
- readonly type: typeof import("mongoose").Schema.Types.Decimal128;
63
- };
64
- readonly required: {
65
- readonly required: true;
66
- readonly type: typeof import("mongoose").Schema.Types.Decimal128;
67
- };
68
- };
69
- readonly number: {
70
- readonly nonRequired: {
71
- readonly type: NumberConstructor;
72
- };
73
- readonly required: {
74
- readonly required: true;
75
- readonly type: NumberConstructor;
76
- };
77
- readonly unique: {
78
- readonly nonRequired: {
79
- readonly type: NumberConstructor;
80
- readonly unique: true;
81
- };
82
- readonly required: {
83
- readonly unique: true;
84
- readonly required: true;
85
- readonly type: NumberConstructor;
86
- };
87
- };
88
- };
89
- readonly objectId: {
90
- readonly nonRequired: {
91
- readonly type: typeof import("mongoose").Schema.Types.ObjectId;
92
- };
93
- readonly required: {
94
- readonly required: true;
95
- readonly type: typeof import("mongoose").Schema.Types.ObjectId;
96
- };
97
- readonly unique: {
98
- readonly nonRequired: {
99
- readonly type: typeof import("mongoose").Schema.Types.ObjectId;
100
- readonly unique: true;
101
- };
102
- readonly required: {
103
- readonly unique: true;
104
- readonly required: true;
105
- readonly type: typeof import("mongoose").Schema.Types.ObjectId;
106
- };
107
- };
108
- };
109
- readonly string: {
110
- readonly ipv4: {
111
- readonly nonRequired: {
112
- readonly trim: true;
113
- readonly type: StringConstructor;
114
- readonly validate: {
115
- readonly message: "`{VALUE}` is not a valid IPv4 address for path `{PATH}`.";
116
- readonly validator: (value: string) => boolean;
117
- };
118
- };
119
- readonly private: {
120
- readonly nonRequired: {
121
- readonly private: true;
122
- readonly trim: true;
123
- readonly type: StringConstructor;
124
- readonly validate: {
125
- readonly message: "`{VALUE}` is not a valid IPv4 address for path `{PATH}`.";
126
- readonly validator: (value: string) => boolean;
127
- };
128
- };
129
- readonly required: {
130
- readonly private: true;
131
- readonly required: true;
132
- readonly trim: true;
133
- readonly type: StringConstructor;
134
- readonly validate: {
135
- readonly message: "`{VALUE}` is not a valid IPv4 address for path `{PATH}`.";
136
- readonly validator: (value: string) => boolean;
137
- };
138
- };
139
- readonly unique: {
140
- readonly nonRequired: {
141
- readonly private: true;
142
- readonly unique: true;
143
- readonly trim: true;
144
- readonly type: StringConstructor;
145
- readonly validate: {
146
- readonly message: "`{VALUE}` is not a valid IPv4 address for path `{PATH}`.";
147
- readonly validator: (value: string) => boolean;
148
- };
149
- };
150
- readonly required: {
151
- readonly private: true;
152
- readonly required: true;
153
- readonly unique: true;
154
- readonly trim: true;
155
- readonly type: StringConstructor;
156
- readonly validate: {
157
- readonly message: "`{VALUE}` is not a valid IPv4 address for path `{PATH}`.";
158
- readonly validator: (value: string) => boolean;
159
- };
160
- };
161
- };
162
- };
163
- readonly required: {
164
- readonly required: true;
165
- readonly trim: true;
166
- readonly type: StringConstructor;
167
- readonly validate: {
168
- readonly message: "`{VALUE}` is not a valid IPv4 address for path `{PATH}`.";
169
- readonly validator: (value: string) => boolean;
170
- };
171
- };
172
- readonly unique: {
173
- readonly nonRequired: {
174
- readonly unique: true;
175
- readonly trim: true;
176
- readonly type: StringConstructor;
177
- readonly validate: {
178
- readonly message: "`{VALUE}` is not a valid IPv4 address for path `{PATH}`.";
179
- readonly validator: (value: string) => boolean;
180
- };
181
- };
182
- readonly required: {
183
- readonly required: true;
184
- readonly unique: true;
185
- readonly trim: true;
186
- readonly type: StringConstructor;
187
- readonly validate: {
188
- readonly message: "`{VALUE}` is not a valid IPv4 address for path `{PATH}`.";
189
- readonly validator: (value: string) => boolean;
190
- };
191
- };
192
- };
193
- };
194
- readonly ipv6: {
195
- readonly nonRequired: {
196
- readonly validate: {
197
- readonly message: "`{VALUE}` is not a valid IPv6 address for path `{PATH}`.";
198
- readonly validator: (value: string) => boolean;
199
- };
200
- readonly trim: true;
201
- readonly type: StringConstructor;
202
- };
203
- readonly private: {
204
- readonly nonRequired: {
205
- readonly private: true;
206
- readonly validate: {
207
- readonly message: "`{VALUE}` is not a valid IPv6 address for path `{PATH}`.";
208
- readonly validator: (value: string) => boolean;
209
- };
210
- readonly trim: true;
211
- readonly type: StringConstructor;
212
- };
213
- readonly required: {
214
- readonly private: true;
215
- readonly required: true;
216
- readonly validate: {
217
- readonly message: "`{VALUE}` is not a valid IPv6 address for path `{PATH}`.";
218
- readonly validator: (value: string) => boolean;
219
- };
220
- readonly trim: true;
221
- readonly type: StringConstructor;
222
- };
223
- readonly unique: {
224
- readonly nonRequired: {
225
- readonly private: true;
226
- readonly unique: true;
227
- readonly validate: {
228
- readonly message: "`{VALUE}` is not a valid IPv6 address for path `{PATH}`.";
229
- readonly validator: (value: string) => boolean;
230
- };
231
- readonly trim: true;
232
- readonly type: StringConstructor;
233
- };
234
- readonly required: {
235
- readonly private: true;
236
- readonly required: true;
237
- readonly unique: true;
238
- readonly validate: {
239
- readonly message: "`{VALUE}` is not a valid IPv6 address for path `{PATH}`.";
240
- readonly validator: (value: string) => boolean;
241
- };
242
- readonly trim: true;
243
- readonly type: StringConstructor;
244
- };
245
- };
246
- };
247
- readonly required: {
248
- readonly required: true;
249
- readonly validate: {
250
- readonly message: "`{VALUE}` is not a valid IPv6 address for path `{PATH}`.";
251
- readonly validator: (value: string) => boolean;
252
- };
253
- readonly trim: true;
254
- readonly type: StringConstructor;
255
- };
256
- readonly unique: {
257
- readonly nonRequired: {
258
- readonly unique: true;
259
- readonly validate: {
260
- readonly message: "`{VALUE}` is not a valid IPv6 address for path `{PATH}`.";
261
- readonly validator: (value: string) => boolean;
262
- };
263
- readonly trim: true;
264
- readonly type: StringConstructor;
265
- };
266
- readonly required: {
267
- readonly required: true;
268
- readonly unique: true;
269
- readonly validate: {
270
- readonly message: "`{VALUE}` is not a valid IPv6 address for path `{PATH}`.";
271
- readonly validator: (value: string) => boolean;
272
- };
273
- readonly trim: true;
274
- readonly type: StringConstructor;
275
- };
276
- };
277
- };
278
- readonly nonRequired: import("./types/schema").MongooseStringSchema<[]>;
279
- readonly private: {
280
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["private"]>;
281
- readonly required: import("./types/schema").MongooseStringSchema<["private", "required"]>;
282
- readonly short: {
283
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["private", "short"]>;
284
- readonly required: import("./types/schema").MongooseStringSchema<["private", "required", "short"]>;
285
- readonly trimmed: {
286
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["private", "short", "trim"]>;
287
- readonly required: import("./types/schema").MongooseStringSchema<["private", "required", "short", "trim"]>;
288
- readonly unique: {
289
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["private", "short", "trim", "unique"]>;
290
- readonly required: import("./types/schema").MongooseStringSchema<["private", "required", "short", "trim", "unique"]>;
291
- };
292
- };
293
- readonly unique: {
294
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["private", "short", "unique"]>;
295
- readonly required: import("./types/schema").MongooseStringSchema<["private", "required", "short", "unique"]>;
296
- };
297
- };
298
- readonly trimmed: {
299
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["private", "trim"]>;
300
- readonly required: import("./types/schema").MongooseStringSchema<["private", "required", "trim"]>;
301
- readonly unique: {
302
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["private", "trim", "unique"]>;
303
- readonly required: import("./types/schema").MongooseStringSchema<["private", "required", "trim", "unique"]>;
304
- };
305
- };
306
- readonly unique: {
307
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["private", "unique"]>;
308
- readonly required: import("./types/schema").MongooseStringSchema<["private", "required", "unique"]>;
309
- };
310
- };
311
- readonly required: import("./types/schema").MongooseStringSchema<["required"]>;
312
- readonly short: {
313
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["short"]>;
314
- readonly required: import("./types/schema").MongooseStringSchema<["required", "short"]>;
315
- readonly trimmed: {
316
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["short", "trim"]>;
317
- readonly required: import("./types/schema").MongooseStringSchema<["required", "short", "trim"]>;
318
- readonly unique: {
319
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["short", "trim", "unique"]>;
320
- readonly required: import("./types/schema").MongooseStringSchema<["required", "short", "trim", "unique"]>;
321
- };
322
- };
323
- readonly unique: {
324
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["short", "unique"]>;
325
- readonly required: import("./types/schema").MongooseStringSchema<["required", "short", "unique"]>;
326
- };
327
- };
328
- readonly trimmed: {
329
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["trim"]>;
330
- readonly required: import("./types/schema").MongooseStringSchema<["required", "trim"]>;
331
- readonly unique: {
332
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["trim", "unique"]>;
333
- readonly required: import("./types/schema").MongooseStringSchema<["required", "trim", "unique"]>;
334
- };
335
- };
336
- readonly unique: {
337
- readonly nonRequired: import("./types/schema").MongooseStringSchema<["unique"]>;
338
- readonly required: import("./types/schema").MongooseStringSchema<["required", "unique"]>;
339
- };
340
- };
341
- };
9
+ export declare const mongooseConnections: MongooseConnections;
package/constants.mjs CHANGED
@@ -1,15 +1,10 @@
1
- import { createCommonMongooseSchemas } from './utils.mjs';
2
- export { mongooseConnections } from './_connections.mjs';
3
-
4
1
  /**
5
- * Common Mongoose schemas.
6
- *
7
- * This constant holds a set of commonly used Mongoose schema definitions, generated
8
- * by the `createCommonMongooseSchemas` utility function. These schemas include common
9
- * field types and configurations used across multiple models.
2
+ * Mongoose connections.
10
3
  *
11
- * @deprecated - Will be removed in the next major version. Use {@link schemaBuilders} instead.
4
+ * This constant is a record of named Mongoose connections, allowing multiple
5
+ * database connections to be managed within the application. An optional `default`
6
+ * connection can also be specified for use when a specific connection is not provided.
12
7
  */
13
- const commonMongooseSchemas = createCommonMongooseSchemas();
8
+ const mongooseConnections = {};
14
9
 
15
- export { commonMongooseSchemas };
10
+ export { mongooseConnections };
package/options.cjs CHANGED
@@ -1,8 +1,14 @@
1
1
  'use strict';
2
2
 
3
+ const _internals = require('./_internals.cjs');
4
+
3
5
  /**
4
- * @deprecated - Will be removed in the next major version. Use {@link setCustomMongooseOptions} instead.
6
+ * Sets custom options.
7
+ *
8
+ * For example, you can set {@link CustomMongooseOptions.beforeModelBuild} to define a function that will be called
9
+ * every time {@link buildMongooseModel} is used. Inside this function, you can modify
10
+ * the schema, allowing you to apply common settings to all global schemas.
5
11
  */
6
- const customMongooseOptions = {};
12
+ const setCustomMongooseOptions = (key, value) => (_internals.customMongooseOptions[key] = value);
7
13
 
8
- exports.customMongooseOptions = customMongooseOptions;
14
+ exports.setCustomMongooseOptions = setCustomMongooseOptions;
package/options.d.ts CHANGED
@@ -1,10 +1,6 @@
1
1
  import type { CustomMongooseOptions } from './types/options';
2
2
  import type { buildMongooseModel } from './utils';
3
3
  export type DoNotUseOrRemoveThisType = typeof buildMongooseModel;
4
- /**
5
- * @deprecated - Will be removed in the next major version. Use {@link setCustomMongooseOptions} instead.
6
- */
7
- export declare const customMongooseOptions: CustomMongooseOptions;
8
4
  /**
9
5
  * Sets custom options.
10
6
  *
package/options.mjs CHANGED
@@ -1,6 +1,12 @@
1
+ import { customMongooseOptions } from './_internals.mjs';
2
+
1
3
  /**
2
- * @deprecated - Will be removed in the next major version. Use {@link setCustomMongooseOptions} instead.
4
+ * Sets custom options.
5
+ *
6
+ * For example, you can set {@link CustomMongooseOptions.beforeModelBuild} to define a function that will be called
7
+ * every time {@link buildMongooseModel} is used. Inside this function, you can modify
8
+ * the schema, allowing you to apply common settings to all global schemas.
3
9
  */
4
- const customMongooseOptions = {};
10
+ const setCustomMongooseOptions = (key, value) => (customMongooseOptions[key] = value);
5
11
 
6
- export { customMongooseOptions };
12
+ export { setCustomMongooseOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kikiutils/mongoose",
3
- "version": "2.0.0-rc.0",
3
+ "version": "2.0.0",
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
  "license": "MIT",
6
6
  "author": "kiki-kanri",
@@ -9,7 +9,7 @@
9
9
  "url": "git+https://github.com/kiki-kanri/kikiutils-node-mongoose.git"
10
10
  },
11
11
  "scripts": {
12
- "build": "ts-project-builder ./src/constants.ts ./src/schema-builders/index.ts ./src/utils.ts --clean --preserve-modules",
12
+ "build": "ts-project-builder ./src/constants.ts ./src/options.ts ./src/schema-builders/index.ts ./src/utils.ts --clean --preserve-modules",
13
13
  "bumplog": "changelogen --bump",
14
14
  "release": "pnpm run build && pnpm run test && changelogen --push --release && sh ./build-and-publish.sh",
15
15
  "test": "jest --coverage"
@@ -1,5 +1,5 @@
1
1
  import type { BooleanSchemaDefinition, DefaultType } from 'mongoose';
2
- type ExtendBooleanSchemaBuilder<Props extends {
2
+ export type ExtendBooleanSchemaBuilder<Props extends {
3
3
  type: BooleanSchemaDefinition;
4
4
  }, ExtraOmitFields extends string> = Omit<BooleanSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
5
5
  export interface BooleanSchemaBuilder<Props extends {
@@ -49,4 +49,3 @@ export interface BooleanSchemaBuilder<Props extends {
49
49
  export declare const booleanSchemaBuilder: (schema?: Record<string, any>) => BooleanSchemaBuilder<{
50
50
  type: BooleanSchemaDefinition;
51
51
  }, never>;
52
- export {};
@@ -1,6 +1,6 @@
1
1
  import type { DefaultType, DateSchemaDefinition } from 'mongoose';
2
2
  import type { MaybeReadonly } from '../types/utils';
3
- type ExtendDateSchemaBuilder<Props extends {
3
+ export type ExtendDateSchemaBuilder<Props extends {
4
4
  type: DateSchemaDefinition;
5
5
  }, ExtraOmitFields extends string> = Omit<DateSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
6
6
  export interface DateSchemaBuilder<Props extends {
@@ -76,4 +76,3 @@ export interface DateSchemaBuilder<Props extends {
76
76
  export declare const dateSchemaBuilder: (schema?: Record<string, any>) => DateSchemaBuilder<{
77
77
  type: DateSchemaDefinition;
78
78
  }, never>;
79
- export {};
@@ -2,7 +2,7 @@ import Decimal from 'decimal.js';
2
2
  import { Schema } from 'mongoose';
3
3
  import type { DefaultType, Types } from 'mongoose';
4
4
  import type { MaybeReadonly } from '../types/utils';
5
- type ExtendDecimal128SchemaBuilder<Props extends {
5
+ export type ExtendDecimal128SchemaBuilder<Props extends {
6
6
  type: Schema.Types.Decimal128;
7
7
  }, ExtraOmitFields extends string> = Omit<Decimal128SchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
8
8
  type ToStringGetterSchema = {
@@ -61,6 +61,7 @@ export interface Decimal128SchemaBuilder<Props extends {
61
61
  *
62
62
  * @param places - The number of decimal places to round to (default is 2).
63
63
  * @param rounding - The rounding strategy from the Decimal.js library (default is Decimal.ROUND_DOWN).
64
+ *
64
65
  * @returns A schema builder with the rounding and toFixed behavior applied to the `set` option in Mongoose.
65
66
  */
66
67
  setRoundAndToFixedSetter: (places?: number, rounding?: Decimal.Rounding) => ExtendDecimal128SchemaBuilder<{
@@ -1,6 +1,6 @@
1
1
  import type { DefaultType, NumberSchemaDefinition } from 'mongoose';
2
2
  import type { MaybeReadonly } from '../types/utils';
3
- type ExtendNumberSchemaBuilder<Props extends {
3
+ export type ExtendNumberSchemaBuilder<Props extends {
4
4
  type: NumberSchemaDefinition;
5
5
  }, ExtraOmitFields extends string> = Omit<NumberSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
6
6
  export interface NumberSchemaBuilder<Props extends {
@@ -76,4 +76,3 @@ export interface NumberSchemaBuilder<Props extends {
76
76
  export declare const numberSchemaBuilder: (schema?: Record<string, any>) => NumberSchemaBuilder<{
77
77
  type: NumberSchemaDefinition;
78
78
  }, never>;
79
- export {};
@@ -1,6 +1,6 @@
1
1
  import type { DefaultType, ObjectIdSchemaDefinition, Types } from 'mongoose';
2
2
  import type { MaybeReadonly } from '../types/utils';
3
- type ExtendObjectIdSchemaBuilder<Props extends {
3
+ export type ExtendObjectIdSchemaBuilder<Props extends {
4
4
  type: ObjectIdSchemaDefinition;
5
5
  }, ExtraOmitFields extends string> = Omit<ObjectIdSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
6
6
  export interface ObjectIdSchemaBuilder<Props extends {
@@ -62,4 +62,3 @@ export interface ObjectIdSchemaBuilder<Props extends {
62
62
  export declare const objectIdSchemaBuilder: (schema?: Record<string, any>) => ObjectIdSchemaBuilder<{
63
63
  type: ObjectIdSchemaDefinition;
64
64
  }, never>;
65
- export {};
@@ -1,6 +1,6 @@
1
1
  import type { DefaultType, Model, ObjectIdSchemaDefinition, Types } from 'mongoose';
2
2
  import type { MaybeReadonly } from '../types/utils';
3
- type ExtendRefSchemaBuilder<Props extends {
3
+ export type ExtendRefSchemaBuilder<Props extends {
4
4
  type: ObjectIdSchemaDefinition;
5
5
  }, ExtraOmitFields extends string> = Omit<RefSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
6
6
  export interface RefSchemaBuilder<Props extends {
@@ -63,4 +63,3 @@ export declare const refSchemaBuilder: <T extends string | Model<any> | ((this:
63
63
  ref: T;
64
64
  type: ObjectIdSchemaDefinition;
65
65
  }>;
66
- export {};
@@ -1,6 +1,6 @@
1
1
  import type { DefaultType, StringSchemaDefinition } from 'mongoose';
2
2
  import type { MaybeReadonly } from '../types/utils';
3
- type ExtendStringSchemaBuilder<Props extends {
3
+ export type ExtendStringSchemaBuilder<Props extends {
4
4
  type: StringSchemaDefinition;
5
5
  }, ExtraOmitFields extends string> = Omit<StringSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
6
6
  type IPSchema<T extends string> = {
@@ -39,6 +39,7 @@ export interface StringSchemaBuilder<Props extends {
39
39
  * Ensures the string is a valid IPv4 address and trims the input. The validation message can be customized.
40
40
  *
41
41
  * @param message - The custom error message to return if validation fails. Defaults to a standard IPv4 validation message.
42
+ *
42
43
  * @returns A schema builder with IPv4 validation and the `trim` option enabled.
43
44
  */
44
45
  ipv4: <T extends string = typeof defaultIPv4ValidateMessage>(message?: T) => ExtendStringSchemaBuilder<{
@@ -49,6 +50,7 @@ export interface StringSchemaBuilder<Props extends {
49
50
  * Ensures the string is a valid IPv6 address and trims the input. The validation message can be customized.
50
51
  *
51
52
  * @param message - The custom error message to return if validation fails. Defaults to a standard IPv6 validation message.
53
+ *
52
54
  * @returns A schema builder with IPv6 validation and the `trim` option enabled.
53
55
  */
54
56
  ipv6: <T extends string = typeof defaultIPv6ValidateMessage>(message?: T) => ExtendStringSchemaBuilder<{
@@ -59,6 +61,7 @@ export interface StringSchemaBuilder<Props extends {
59
61
  * This method ensures the string length is exactly or within a specified range.
60
62
  *
61
63
  * @param value - A number representing the exact length or an array specifying [minimum, maximum] length.
64
+ *
62
65
  * @returns A schema builder with both `maxlength` and `minlength` options applied.
63
66
  */
64
67
  length: <T extends L | MaybeReadonly<[L, S]>, L extends number, S extends string>(value: T) => ExtendStringSchemaBuilder<{