@kikiutils/mongoose 2.0.0-rc.1 → 2.0.1
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 +10 -12
- package/_internals.cjs +0 -9
- package/_internals.d.ts +0 -9
- package/_internals.mjs +1 -9
- package/constants.cjs +6 -12
- package/constants.d.ts +6 -338
- package/constants.mjs +6 -11
- package/options.cjs +0 -5
- package/options.d.ts +0 -4
- package/options.mjs +3 -7
- package/package.json +7 -12
- package/schema-builders/boolean.d.ts +1 -2
- package/schema-builders/date.d.ts +1 -2
- package/schema-builders/decimal128.d.ts +1 -1
- package/schema-builders/number.d.ts +1 -2
- package/schema-builders/object-id.d.ts +1 -2
- package/schema-builders/ref.d.ts +1 -2
- package/schema-builders/string.d.ts +1 -1
- package/utils.cjs +6 -307
- package/utils.d.ts +1 -413
- package/utils.mjs +5 -299
- package/types/schema.d.ts +0 -142
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:
|
|
15
|
-
-
|
|
16
|
-
- 🛠 Predefined Schemas: Provides
|
|
17
|
-
-
|
|
18
|
-
- 🔄
|
|
19
|
-
-
|
|
20
|
-
-
|
|
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
|
-
|
|
39
|
+
## Usage
|
|
42
40
|
|
|
43
41
|
Please refer to the [examples](./examples/README.md) folder for usage instructions of this package.
|
|
44
42
|
|
package/_internals.cjs
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const customMongooseOptions = {};
|
|
4
|
-
/**
|
|
5
|
-
* Mongoose connections.
|
|
6
|
-
*
|
|
7
|
-
* This constant is a record of named Mongoose connections, allowing multiple
|
|
8
|
-
* database connections to be managed within the application. An optional `default`
|
|
9
|
-
* connection can also be specified for use when a specific connection is not provided.
|
|
10
|
-
*/
|
|
11
|
-
const mongooseConnections = {};
|
|
12
4
|
|
|
13
5
|
exports.customMongooseOptions = customMongooseOptions;
|
|
14
|
-
exports.mongooseConnections = mongooseConnections;
|
package/_internals.d.ts
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
import type { MongooseConnections } from './types';
|
|
2
1
|
import type { CustomMongooseOptions } from './types/options';
|
|
3
2
|
export declare const customMongooseOptions: CustomMongooseOptions;
|
|
4
|
-
/**
|
|
5
|
-
* Mongoose connections.
|
|
6
|
-
*
|
|
7
|
-
* This constant is a record of named Mongoose connections, allowing multiple
|
|
8
|
-
* database connections to be managed within the application. An optional `default`
|
|
9
|
-
* connection can also be specified for use when a specific connection is not provided.
|
|
10
|
-
*/
|
|
11
|
-
export declare const mongooseConnections: MongooseConnections;
|
package/_internals.mjs
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
const customMongooseOptions = {};
|
|
2
|
-
/**
|
|
3
|
-
* Mongoose connections.
|
|
4
|
-
*
|
|
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.
|
|
8
|
-
*/
|
|
9
|
-
const mongooseConnections = {};
|
|
10
2
|
|
|
11
|
-
export { customMongooseOptions
|
|
3
|
+
export { customMongooseOptions };
|
package/constants.cjs
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const utils = require('./utils.cjs');
|
|
4
|
-
const _internals = require('./_internals.cjs');
|
|
5
|
-
|
|
6
3
|
/**
|
|
7
|
-
*
|
|
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
|
-
*
|
|
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
|
|
10
|
+
const mongooseConnections = {};
|
|
16
11
|
|
|
17
|
-
exports.mongooseConnections =
|
|
18
|
-
exports.commonMongooseSchemas = commonMongooseSchemas;
|
|
12
|
+
exports.mongooseConnections = mongooseConnections;
|
package/constants.d.ts
CHANGED
|
@@ -1,341 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export { mongooseConnections } from './_internals';
|
|
3
|
-
export type DoNotUseOrRemoveThisType = typeof schemaBuilders;
|
|
1
|
+
import type { MongooseConnections } from './types';
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
3
|
+
* Mongoose connections.
|
|
6
4
|
*
|
|
7
|
-
* This constant
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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
|
|
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 './_internals.mjs';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
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
|
-
*
|
|
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
|
|
8
|
+
const mongooseConnections = {};
|
|
14
9
|
|
|
15
|
-
export {
|
|
10
|
+
export { mongooseConnections };
|
package/options.cjs
CHANGED
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const _internals = require('./_internals.cjs');
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated - Will be removed in the next major version. Use {@link setCustomMongooseOptions} instead.
|
|
7
|
-
*/
|
|
8
|
-
const customMongooseOptions = {};
|
|
9
5
|
/**
|
|
10
6
|
* Sets custom options.
|
|
11
7
|
*
|
|
@@ -15,5 +11,4 @@ const customMongooseOptions = {};
|
|
|
15
11
|
*/
|
|
16
12
|
const setCustomMongooseOptions = (key, value) => (_internals.customMongooseOptions[key] = value);
|
|
17
13
|
|
|
18
|
-
exports.customMongooseOptions = customMongooseOptions;
|
|
19
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,9 +1,5 @@
|
|
|
1
|
-
import { customMongooseOptions
|
|
1
|
+
import { customMongooseOptions } from './_internals.mjs';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated - Will be removed in the next major version. Use {@link setCustomMongooseOptions} instead.
|
|
5
|
-
*/
|
|
6
|
-
const customMongooseOptions = {};
|
|
7
3
|
/**
|
|
8
4
|
* Sets custom options.
|
|
9
5
|
*
|
|
@@ -11,6 +7,6 @@ const customMongooseOptions = {};
|
|
|
11
7
|
* every time {@link buildMongooseModel} is used. Inside this function, you can modify
|
|
12
8
|
* the schema, allowing you to apply common settings to all global schemas.
|
|
13
9
|
*/
|
|
14
|
-
const setCustomMongooseOptions = (key, value) => (customMongooseOptions
|
|
10
|
+
const setCustomMongooseOptions = (key, value) => (customMongooseOptions[key] = value);
|
|
15
11
|
|
|
16
|
-
export {
|
|
12
|
+
export { setCustomMongooseOptions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kikiutils/mongoose",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
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",
|
|
@@ -17,21 +17,21 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"decimal.js": "^10.4.3",
|
|
19
19
|
"lodash": "^4.17.21",
|
|
20
|
-
"mongoose": "^8.
|
|
20
|
+
"mongoose": "^8.8.0",
|
|
21
21
|
"mongoose-aggregate-paginate-v2": "^1.1.2",
|
|
22
22
|
"mongoose-paginate-v2": "^1.8.5"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@kikiutils/changelogen": "^0.7.0",
|
|
26
26
|
"@kikiutils/prettierrc": "^1.3.2",
|
|
27
|
-
"@kikiutils/tsconfigs": "^3.0.
|
|
27
|
+
"@kikiutils/tsconfigs": "^3.0.2",
|
|
28
28
|
"@types/jest": "^29.5.14",
|
|
29
|
-
"@types/lodash": "^4.17.
|
|
30
|
-
"@types/node": "^22.
|
|
29
|
+
"@types/lodash": "^4.17.13",
|
|
30
|
+
"@types/node": "^22.8.6",
|
|
31
31
|
"jest": "^29.7.0",
|
|
32
32
|
"ts-jest": "^29.2.5",
|
|
33
33
|
"ts-project-builder": "^3.3.0",
|
|
34
|
-
"tslib": "^2.8.
|
|
34
|
+
"tslib": "^2.8.1"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [
|
|
37
37
|
"Decimal128",
|
|
@@ -52,12 +52,7 @@
|
|
|
52
52
|
"require": "./*.cjs",
|
|
53
53
|
"types": "./*.d.ts"
|
|
54
54
|
},
|
|
55
|
-
"./
|
|
56
|
-
"import": null,
|
|
57
|
-
"require": null,
|
|
58
|
-
"types": null
|
|
59
|
-
},
|
|
60
|
-
"./_options": {
|
|
55
|
+
"./_internals": {
|
|
61
56
|
"import": null,
|
|
62
57
|
"require": null,
|
|
63
58
|
"types": null
|
|
@@ -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 = {
|
|
@@ -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 {};
|