@aeriajs/types 0.0.7 → 0.0.10
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/dist/functions.d.ts +4 -6
- package/dist/schema.d.ts +4 -4
- package/package.json +1 -1
package/dist/functions.d.ts
CHANGED
|
@@ -10,15 +10,13 @@ export type Pagination = {
|
|
|
10
10
|
offset: number;
|
|
11
11
|
limit: number;
|
|
12
12
|
};
|
|
13
|
-
export type StrictFilterOperators<TDocument> = FilterOperators<TDocument
|
|
13
|
+
export type StrictFilterOperators<TDocument> = FilterOperators<PackReferences<TDocument, true>> extends infer InferredFilters ? {
|
|
14
14
|
[P in keyof InferredFilters as 0 extends (InferredFilters[P] & 1) ? never : P]: InferredFilters[P];
|
|
15
15
|
} : never;
|
|
16
16
|
export type Filters<TDocument> = Partial<{
|
|
17
|
-
[P in keyof TDocument]: TDocument[P] | StrictFilterOperators<TDocument[P]>;
|
|
17
|
+
[P in keyof TDocument]: PackReferences<TDocument, true>[P] | StrictFilterOperators<PackReferences<TDocument, true>[P]>;
|
|
18
18
|
}>;
|
|
19
|
-
export type What<TDocument> =
|
|
20
|
-
[P in keyof TDocument]?: '_id' extends keyof TDocument[P] ? TDocument[P] | string : TDocument[P];
|
|
21
|
-
};
|
|
19
|
+
export type What<TDocument> = Partial<PackReferences<TDocument, true>> & StrictUpdateFilter<TDocument>;
|
|
22
20
|
export type Projection<TDocument> = keyof TDocument | '_id' extends infer DocumentProp ? TDocument extends string ? DocumentProp[] : string[] : never;
|
|
23
21
|
export type QuerySort<TDocument> = Partial<Record<keyof WithId<TDocument>, 1 | -1>>;
|
|
24
22
|
export type CollectionDocument<TDocument> = TDocument;
|
|
@@ -39,7 +37,7 @@ export type GetAllPayload<TDocument extends CollectionDocument<OptionalId<any>>>
|
|
|
39
37
|
populate?: (keyof TDocument | string)[];
|
|
40
38
|
};
|
|
41
39
|
export type InsertPayload<TDocument extends CollectionDocument<any>, BypassTypeRestriction = false> = {
|
|
42
|
-
what: BypassTypeRestriction extends true ? any : What<
|
|
40
|
+
what: BypassTypeRestriction extends true ? any : What<TDocument>;
|
|
43
41
|
project?: Projection<TDocument>;
|
|
44
42
|
};
|
|
45
43
|
export type RemovePayload<TDocument extends CollectionDocument<OptionalId<any>>> = {
|
package/dist/schema.d.ts
CHANGED
|
@@ -64,8 +64,8 @@ export type ObjectToSchema<TObject, TRequired extends string[] | null = null> =
|
|
|
64
64
|
required: TRequired;
|
|
65
65
|
properties: Properties;
|
|
66
66
|
} : never;
|
|
67
|
-
export type PackReferences<T> = {
|
|
68
|
-
[P in keyof T]: PackReferencesAux<T[P]>;
|
|
67
|
+
export type PackReferences<T, AllowCoercion = false> = {
|
|
68
|
+
[P in keyof T]: PackReferencesAux<T[P], AllowCoercion>;
|
|
69
69
|
};
|
|
70
70
|
export type FilterReadonlyProperties<TProperties> = {
|
|
71
71
|
[P in keyof TProperties as TProperties[P] extends {
|
|
@@ -89,9 +89,9 @@ type MapReferences<TSchema> = TSchema extends {
|
|
|
89
89
|
}>;
|
|
90
90
|
}> ? K extends keyof Collections ? Collections[K]['item'][] : never : never : never;
|
|
91
91
|
} : never;
|
|
92
|
-
type PackReferencesAux<T> = T extends (...args: any[]) => any ? T : T extends {
|
|
92
|
+
type PackReferencesAux<T, AllowCoercion = false> = T extends (...args: any[]) => any ? T : T extends ObjectId ? AllowCoercion extends true ? T | string : T : T extends {
|
|
93
93
|
_id: infer Id;
|
|
94
|
-
} ? Id : T extends Record<string, any> ? PackReferences<T> : T extends any[] | readonly any[] ? PackReferencesAux<T[number]>[] : T;
|
|
94
|
+
} ? AllowCoercion extends true ? Id | string : Id : T extends Record<string, any> ? PackReferences<T, AllowCoercion> : T extends any[] | readonly any[] ? PackReferencesAux<T[number], AllowCoercion>[] : T;
|
|
95
95
|
type CombineProperties<TSchema> = TSchema extends {
|
|
96
96
|
properties: infer Properties;
|
|
97
97
|
} ? FilterReadonlyProperties<Properties> extends infer ReadonlyProperties ? Readonly<ReadonlyProperties> & {
|