Skip to content

Commit c4a9f85

Browse files
chore: rename types
1 parent 55b3787 commit c4a9f85

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,6 @@ export type {
309309
BitwiseFilter,
310310
BSONTypeAlias,
311311
Condition,
312-
DotNotationFilter,
313-
DotNotationMatchKeysAndValues,
314-
DotNotationUpdateFilter,
315312
EnhancedOmit,
316313
Filter,
317314
FilterOperations,
@@ -341,6 +338,9 @@ export type {
341338
RootFilterOperators,
342339
SchemaMember,
343340
SetFields,
341+
StrictFilter,
342+
StrictMatchKeysAndValues,
343+
StrictUpdateFilter,
344344
UpdateFilter,
345345
WithId,
346346
WithoutId

src/mongo_types.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ export type NestedPathsOfType<TSchema, Type> = KeysOfAType<
530530
* @public
531531
* @experimental
532532
*/
533-
export type DotNotationFilter<TSchema> =
533+
export type StrictFilter<TSchema> =
534534
| Partial<TSchema>
535535
| ({
536536
[Property in Join<NestedPaths<WithId<TSchema>, []>, '.'>]?: Condition<
@@ -542,19 +542,19 @@ export type DotNotationFilter<TSchema> =
542542
* @public
543543
* @experimental
544544
*/
545-
export type DotNotationUpdateFilter<TSchema> = {
545+
export type StrictUpdateFilter<TSchema> = {
546546
$currentDate?: OnlyFieldsOfType<
547547
TSchema,
548548
Date | Timestamp,
549549
true | { $type: 'date' | 'timestamp' }
550550
>;
551551
$inc?: OnlyFieldsOfType<TSchema, NumericType | undefined>;
552-
$min?: DotNotationMatchKeysAndValues<TSchema>;
553-
$max?: DotNotationMatchKeysAndValues<TSchema>;
552+
$min?: StrictMatchKeysAndValues<TSchema>;
553+
$max?: StrictMatchKeysAndValues<TSchema>;
554554
$mul?: OnlyFieldsOfType<TSchema, NumericType | undefined>;
555555
$rename?: Record<string, string>;
556-
$set?: DotNotationMatchKeysAndValues<TSchema>;
557-
$setOnInsert?: DotNotationMatchKeysAndValues<TSchema>;
556+
$set?: StrictMatchKeysAndValues<TSchema>;
557+
$setOnInsert?: StrictMatchKeysAndValues<TSchema>;
558558
$unset?: OnlyFieldsOfType<TSchema, any, '' | true | 1>;
559559
$addToSet?: SetFields<TSchema>;
560560
$pop?: OnlyFieldsOfType<TSchema, ReadonlyArray<any>, 1 | -1>;
@@ -568,8 +568,11 @@ export type DotNotationUpdateFilter<TSchema> = {
568568
>;
569569
} & Document;
570570

571-
/** @public */
572-
export type DotNotationMatchKeysAndValues<TSchema> = Readonly<
571+
/**
572+
* @public
573+
* @experimental
574+
*/
575+
export type StrictMatchKeysAndValues<TSchema> = Readonly<
573576
{
574577
[Property in Join<NestedPaths<TSchema, []>, '.'>]?: PropertyType<TSchema, Property>;
575578
} & {

test/types/community/collection/recursive-types.test-d.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { expectAssignable, expectError, expectNotAssignable, expectNotType } fro
22

33
import type {
44
Collection,
5-
DotNotationFilter,
6-
DotNotationUpdateFilter,
5+
StrictFilter,
6+
StrictUpdateFilter,
77
UpdateFilter
88
} from '../../../../src';
99

@@ -20,7 +20,7 @@ interface Book {
2020
author: Author;
2121
}
2222

23-
expectAssignable<DotNotationFilter<Author>>({
23+
expectAssignable<StrictFilter<Author>>({
2424
bestBook: {
2525
title: 'book title',
2626
author: {
@@ -45,41 +45,41 @@ expectNotType<UpdateFilter<Author>>({
4545

4646
//////////// Filter
4747
// Depth of 1 has type checking
48-
expectNotAssignable<DotNotationFilter<Author>>({
48+
expectNotAssignable<StrictFilter<Author>>({
4949
'bestBook.title': 23
5050
});
5151
// Depth of 2 has type checking
52-
expectNotAssignable<DotNotationFilter<Author>>({
52+
expectNotAssignable<StrictFilter<Author>>({
5353
'bestBook.author.name': 23
5454
});
5555
// Depth of 3 has type checking
56-
expectNotAssignable<DotNotationFilter<Author>>({
56+
expectNotAssignable<StrictFilter<Author>>({
5757
'bestBook.author.bestBook.title': 23
5858
});
5959
// Depth of 4 has type checking
60-
expectNotAssignable<DotNotationFilter<Author>>({
60+
expectNotAssignable<StrictFilter<Author>>({
6161
'bestBook.author.bestBook.author.name': 23
6262
});
6363
// Depth of 5 has type checking
64-
expectNotAssignable<DotNotationFilter<Author>>({
64+
expectNotAssignable<StrictFilter<Author>>({
6565
'bestBook.author.bestBook.author.bestBook.title': 23
6666
});
6767
// Depth of 6 has type checking
68-
expectNotAssignable<DotNotationFilter<Author>>({
68+
expectNotAssignable<StrictFilter<Author>>({
6969
'bestBook.author.bestBook.author.bestBook.author.name': 23
7070
});
7171
// Depth of 7 has type checking
72-
expectNotAssignable<DotNotationFilter<Author>>({
72+
expectNotAssignable<StrictFilter<Author>>({
7373
'bestBook.author.bestBook.author.bestBook.author.bestBook.title': 23
7474
});
7575
// Depth of 8 does **not** have type checking
76-
expectAssignable<DotNotationFilter<Author>>({
76+
expectAssignable<StrictFilter<Author>>({
7777
'bestBook.author.bestBook.author.bestBook.author.bestBook.author.name': 23
7878
});
7979

8080
//////////// UpdateFilter
8181
// Depth of 1 has type checking
82-
expectNotAssignable<DotNotationUpdateFilter<Author>>({
82+
expectNotAssignable<StrictUpdateFilter<Author>>({
8383
$set: {
8484
'bestBook.title': 23
8585
}
@@ -286,12 +286,12 @@ type D = {
286286
a: A;
287287
};
288288

289-
expectAssignable<DotNotationFilter<A>>({
289+
expectAssignable<StrictFilter<A>>({
290290
'b.c.d.a.b.c.d.a.b.name': 'a'
291291
});
292292

293293
// Beyond the depth supported, there is no type checking
294-
expectAssignable<DotNotationFilter<A>>({
294+
expectAssignable<StrictFilter<A>>({
295295
'b.c.d.a.b.c.d.a.b.c.name': 3
296296
});
297297

test/types/community/collection/updateX.test-d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expectAssignable, expectError, expectNotAssignable, expectNotType } fro
33
import type {
44
AddToSetOperators,
55
ArrayOperator,
6-
DotNotationUpdateFilter,
6+
StrictUpdateFilter,
77
MatchKeysAndValues,
88
PullAllOperator,
99
PullOperator,
@@ -108,7 +108,7 @@ const collectionTType = db.collection<TestModel>('test.update');
108108

109109
function buildUpdateFilter(
110110
updateQuery: UpdateFilter<TestModel>
111-
): DotNotationUpdateFilter<TestModel> {
111+
): StrictUpdateFilter<TestModel> {
112112
return updateQuery;
113113
}
114114

@@ -217,10 +217,10 @@ expectAssignable<UpdateFilter<TestModel>>({ $set: { 'subInterfaceField.nestedObj
217217
expectAssignable<UpdateFilter<TestModel>>({
218218
$set: { 'subInterfaceField.nestedObject': { a: '1', b: '2' } }
219219
});
220-
expectError<DotNotationUpdateFilter<TestModel>>({
220+
expectError<StrictUpdateFilter<TestModel>>({
221221
$set: { 'subInterfaceField.nestedObject': { a: '1' } }
222222
});
223-
expectError<DotNotationUpdateFilter<TestModel>>({
223+
expectError<StrictUpdateFilter<TestModel>>({
224224
$set: { 'subInterfaceField.nestedObject': { a: 1, b: '2' } }
225225
});
226226

0 commit comments

Comments
 (0)