mongoose 9.7.2 → 9.7.4
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/package.json +8 -7
- package/types/index.d.ts +7 -5
- package/types/models.d.ts +10 -41
- package/types/utility.d.ts +9 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "9.7.
|
|
4
|
+
"version": "9.7.4",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"type": "commonjs",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@standard-schema/spec": "^1.1.0",
|
|
23
24
|
"kareem": "3.3.0",
|
|
24
25
|
"mongodb": "~7.2",
|
|
25
26
|
"mpath": "0.9.0",
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
"sift": "17.1.3"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@ark/attest": "0.56.
|
|
32
|
+
"@ark/attest": "0.56.1",
|
|
32
33
|
"@eslint/js": "^9.39.3",
|
|
33
34
|
"@mongodb-js/mongodb-downloader": "^1.0.0",
|
|
34
35
|
"@types/node": "^20.19.0",
|
|
@@ -39,18 +40,18 @@
|
|
|
39
40
|
"c8": "11.0.0",
|
|
40
41
|
"cheerio": "1.2.0",
|
|
41
42
|
"dox": "1.0.0",
|
|
42
|
-
"eslint": "10.
|
|
43
|
+
"eslint": "10.6.0",
|
|
43
44
|
"eslint-plugin-mocha-no-only": "1.2.0",
|
|
44
45
|
"express": "5.2.1",
|
|
45
46
|
"fs-extra": "~11.3.0",
|
|
46
|
-
"globals": "^17.4.0",
|
|
47
47
|
"glob": "^13.0.6",
|
|
48
|
+
"globals": "^17.4.0",
|
|
48
49
|
"highlight.js": "11.11.1",
|
|
49
50
|
"linkinator": "7.x",
|
|
50
51
|
"lodash.isequal": "4.5.0",
|
|
51
52
|
"lodash.isequalwith": "4.4.0",
|
|
52
53
|
"markdownlint-cli2": "0.22.1",
|
|
53
|
-
"marked": "18.0.
|
|
54
|
+
"marked": "18.0.5",
|
|
54
55
|
"mkdirp": "^3.0.1",
|
|
55
56
|
"mocha": "12.0.0-beta-10",
|
|
56
57
|
"moment": "2.30.1",
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
"tstyche": "^7.0.0",
|
|
64
65
|
"typescript": "5.9.3",
|
|
65
66
|
"typescript-eslint": "^8.31.1",
|
|
66
|
-
"uuid": "14.0.
|
|
67
|
+
"uuid": "14.0.1",
|
|
67
68
|
"xss": "1.0.15"
|
|
68
69
|
},
|
|
69
70
|
"directories": {
|
|
@@ -86,7 +87,7 @@
|
|
|
86
87
|
"docs:prepare:publish:6x": "git checkout 6.x && git merge 6.x && npm run docs:clean:stable && env DOCS_DEPLOY=true npm run docs:generate && mv ./docs/6.x ./tmp && git checkout gh-pages && npm run docs:copy:tmp:6x",
|
|
87
88
|
"docs:prepare:publish:7x": "env DOCS_DEPLOY=true npm run docs:generate && git checkout gh-pages && rm -rf ./docs/7.x && mv ./tmp ./docs/7.x",
|
|
88
89
|
"docs:prepare:publish:8x": "env DOCS_DEPLOY=true npm run docs:generate && git checkout gh-pages && rm -rf ./docs/8.x && mv ./tmp ./docs/8.x",
|
|
89
|
-
"docs:check-links": "linkinator http://127.0.0.1:8089 --silent --recurse --skip cdn.carbonads.com --skip m.servedby-buysellads.com --skip \"127\\.0\\.0\\.1:8089
|
|
90
|
+
"docs:check-links": "linkinator http://127.0.0.1:8089 --silent --recurse --skip cdn.carbonads.com --skip m.servedby-buysellads.com --skip \"127\\.0\\.0\\.1:8089/docs/\\d+.x\"",
|
|
90
91
|
"docs:update-mongodb-links": "node ./scripts/update-mongodb-links.js",
|
|
91
92
|
"lint": "eslint .",
|
|
92
93
|
"lint-js": "eslint . --ext .js --ext .cjs",
|
package/types/index.d.ts
CHANGED
|
@@ -191,11 +191,13 @@ declare module 'mongoose' {
|
|
|
191
191
|
Document<unknown, TQueryHelpers, RawDocType, TVirtuals, TSchemaOptions> & Default__v<Require_id<HydratedDocPathsType>, TSchemaOptions>,
|
|
192
192
|
Document<unknown, TQueryHelpers, RawDocType, TVirtuals, TSchemaOptions> & MergeType<
|
|
193
193
|
Default__v<Require_id<HydratedDocPathsType>, TSchemaOptions>,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
HydratedDocumentOverrides<
|
|
195
|
+
IfEquals<
|
|
196
|
+
TOverrides,
|
|
197
|
+
{},
|
|
198
|
+
TOverrides,
|
|
199
|
+
TOverrides & AddDefaultId<HydratedDocPathsType, TVirtuals, TSchemaOptions>
|
|
200
|
+
>
|
|
199
201
|
>
|
|
200
202
|
>
|
|
201
203
|
>
|
package/types/models.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare module 'mongoose' {
|
|
2
2
|
import mongodb = require('mongodb');
|
|
3
|
+
import { StandardSchemaV1 as StandardSchemaV1Spec, StandardTypedV1 as StandardTypedV1Spec } from '@standard-schema/spec';
|
|
3
4
|
|
|
4
5
|
export interface DiscriminatorOptions {
|
|
5
6
|
value?: string | number | ObjectId;
|
|
@@ -108,40 +109,8 @@ declare module 'mongoose' {
|
|
|
108
109
|
*/
|
|
109
110
|
type pathsToValidate = PathsToValidate;
|
|
110
111
|
|
|
111
|
-
export
|
|
112
|
-
|
|
113
|
-
readonly version: 1;
|
|
114
|
-
readonly vendor: 'mongoose';
|
|
115
|
-
readonly validate: (
|
|
116
|
-
value: unknown,
|
|
117
|
-
options?: Options | undefined
|
|
118
|
-
) => Result<Output> | Promise<Result<Output>>;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface Options {
|
|
122
|
-
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
126
|
-
|
|
127
|
-
export interface SuccessResult<Output> {
|
|
128
|
-
readonly value: Output;
|
|
129
|
-
readonly issues?: undefined;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export interface FailureResult {
|
|
133
|
-
readonly issues: ReadonlyArray<Issue>;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export interface Issue {
|
|
137
|
-
readonly message: string;
|
|
138
|
-
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export interface PathSegment {
|
|
142
|
-
readonly key: PropertyKey;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
112
|
+
export import StandardTypedV1 = StandardTypedV1Spec;
|
|
113
|
+
export import StandardSchemaV1 = StandardSchemaV1Spec;
|
|
145
114
|
|
|
146
115
|
interface SaveOptions extends
|
|
147
116
|
SessionOption {
|
|
@@ -224,7 +193,7 @@ declare module 'mongoose' {
|
|
|
224
193
|
* - vanilla arrays of POJOs for document arrays
|
|
225
194
|
* - POJOs and array of arrays for maps
|
|
226
195
|
*/
|
|
227
|
-
type CreateObjectWithExtraKeys<T> = T & Record<string, unknown
|
|
196
|
+
type CreateObjectWithExtraKeys<T> = T | (T & Record<string, unknown>);
|
|
228
197
|
type ApplyBasicCreateCasting<T> = {
|
|
229
198
|
[K in keyof T]: NonNullable<T[K]> extends Map<infer KeyType extends string, infer ValueType>
|
|
230
199
|
? (Record<KeyType, ValueType> | Array<[KeyType, ValueType]> | T[K] | QueryTypeCasting<Extract<T[K], TreatAsPrimitives>>)
|
|
@@ -270,7 +239,7 @@ declare module 'mongoose' {
|
|
|
270
239
|
base: Mongoose;
|
|
271
240
|
|
|
272
241
|
/** Standard Schema adapter for validating input with this model's schema. */
|
|
273
|
-
readonly '~standard': StandardSchemaV1.Props<TRawDocType
|
|
242
|
+
readonly '~standard': StandardSchemaV1.Props<Default__v<Require_id<TRawDocType>, ObtainSchemaGeneric<TSchema, 'TSchemaOptions'>>>;
|
|
274
243
|
|
|
275
244
|
/**
|
|
276
245
|
* If this is a discriminator model, `baseModelName` is the name of
|
|
@@ -684,11 +653,11 @@ declare module 'mongoose' {
|
|
|
684
653
|
*/
|
|
685
654
|
useConnection(connection: Connection): this;
|
|
686
655
|
|
|
687
|
-
/** Casts and validates the given object against this model's schema, passing the given `context` to custom validators. */
|
|
688
|
-
validate(): Promise<
|
|
689
|
-
validate(obj: any): Promise<
|
|
690
|
-
validate(obj: any, pathsOrOptions: PathsToValidate): Promise<
|
|
691
|
-
validate(obj: any, pathsOrOptions: { pathsToSkip?: pathsToSkip }): Promise<
|
|
656
|
+
/** Casts and validates the given object against this model's schema, returning the casted-and-validated copy of `obj`, passing the given `context` to custom validators. */
|
|
657
|
+
validate(): Promise<TRawDocType>;
|
|
658
|
+
validate(obj: any): Promise<TRawDocType>;
|
|
659
|
+
validate(obj: any, pathsOrOptions: PathsToValidate): Promise<TRawDocType>;
|
|
660
|
+
validate(obj: any, pathsOrOptions: { pathsToSkip?: pathsToSkip }): Promise<TRawDocType>;
|
|
692
661
|
|
|
693
662
|
/** Watches the underlying collection for changes using [MongoDB change streams](https://www.mongodb.com/docs/manual/changeStreams/). */
|
|
694
663
|
watch<ResultType extends mongodb.Document = any, ChangeType extends mongodb.ChangeStreamDocument = any>(pipeline?: Array<Record<string, unknown>>, options?: mongodb.ChangeStreamOptions & { hydrate?: boolean }): mongodb.ChangeStream<ResultType, ChangeType>;
|
package/types/utility.d.ts
CHANGED
|
@@ -161,6 +161,15 @@ declare module 'mongoose' {
|
|
|
161
161
|
: T[K];
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
+
type OmitThisParameterIfFunction<T> = T extends (...args: any[]) => any ? OmitThisParameter<T> : T;
|
|
165
|
+
|
|
166
|
+
// Strip explicit `this` parameter from methods in schema type options. The `this` parameter
|
|
167
|
+
// is just for type-checking the function body. Keeping the explicit 'this' typing can cause
|
|
168
|
+
// compiler errors on the method calls, so remove it for the hydrated document definition.
|
|
169
|
+
type HydratedDocumentOverrides<T> = {
|
|
170
|
+
[K in keyof T]: OmitThisParameterIfFunction<T[K]>;
|
|
171
|
+
};
|
|
172
|
+
|
|
164
173
|
/**
|
|
165
174
|
* @summary Adds timestamp fields to a type
|
|
166
175
|
* @description Adds createdAt and updatedAt fields of type Date, or custom timestamp fields if specified
|