@aeriajs/types 0.0.10 → 0.0.13
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 +19 -13
- package/dist/schema.d.ts +4 -4
- package/package.json +1 -1
package/dist/functions.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FilterOperators, StrictUpdateFilter, WithId, OptionalId, ObjectId } from 'mongodb';
|
|
2
|
-
import type { PackReferences, Either, ValidationError, ACErrors
|
|
1
|
+
import type { FilterOperators, StrictFilter as Filter, StrictUpdateFilter, WithId, OptionalId, ObjectId } from 'mongodb';
|
|
2
|
+
import type { PackReferences, Either, ValidationError, ACErrors } from '.';
|
|
3
3
|
export type UploadAuxProps = {
|
|
4
4
|
parentId: string;
|
|
5
5
|
propertyName: string;
|
|
@@ -10,13 +10,24 @@ export type Pagination = {
|
|
|
10
10
|
offset: number;
|
|
11
11
|
limit: number;
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
[P in keyof
|
|
13
|
+
type DocumentFilter<TDocument> = PackReferences<TDocument> extends infer Document ? {
|
|
14
|
+
[P in keyof Document]: null | (Document[P] extends ObjectId ? Document[P] | string : Document[P]);
|
|
15
15
|
} : never;
|
|
16
|
-
|
|
17
|
-
[P in keyof
|
|
16
|
+
type RemoveAny<T> = {
|
|
17
|
+
[P in keyof T as 0 extends (T[P] & 1) ? never : P]: T[P];
|
|
18
|
+
};
|
|
19
|
+
export type StrictFilter<TDocument> = RemoveAny<Filter<DocumentFilter<TDocument>>>;
|
|
20
|
+
export type StrictFilterOperators<TDocument> = RemoveAny<FilterOperators<DocumentFilter<TDocument>>>;
|
|
21
|
+
export type Filters<TDocument> = StrictFilter<any> & Partial<{
|
|
22
|
+
[P in keyof TDocument]: null | (TDocument[P] extends infer Field ? Field extends ObjectId ? Field | string : Field extends {
|
|
23
|
+
_id: infer Id;
|
|
24
|
+
} ? Id | string : Field : never) extends infer Field ? Field | StrictFilterOperators<Field> | null : never;
|
|
18
25
|
}>;
|
|
19
|
-
export type What<TDocument> =
|
|
26
|
+
export type What<TDocument> = DocumentFilter<TDocument> extends infer Document ? Partial<{
|
|
27
|
+
[P in keyof Document]: Document[P] extends null ? null : Document[P] | StrictUpdateFilter<Document[P]>;
|
|
28
|
+
}> & {
|
|
29
|
+
_id?: ObjectId | string;
|
|
30
|
+
} : never;
|
|
20
31
|
export type Projection<TDocument> = keyof TDocument | '_id' extends infer DocumentProp ? TDocument extends string ? DocumentProp[] : string[] : never;
|
|
21
32
|
export type QuerySort<TDocument> = Partial<Record<keyof WithId<TDocument>, 1 | -1>>;
|
|
22
33
|
export type CollectionDocument<TDocument> = TDocument;
|
|
@@ -66,9 +77,4 @@ export type CollectionFunctionsPaginated<TDocument extends CollectionDocument<Op
|
|
|
66
77
|
pagination: Pagination;
|
|
67
78
|
}>;
|
|
68
79
|
};
|
|
69
|
-
export
|
|
70
|
-
insert: (payload: InsertPayload<TDocument, true>) => Promise<Either<ValidationError | ACErrors, TDocument>>;
|
|
71
|
-
};
|
|
72
|
-
export type CollectionFunctionsWithContext<TDocument extends CollectionDocument<OptionalId<any>>, TDescription extends Description = any, TFunctions = any> = {
|
|
73
|
-
[P in keyof CollectionFunctionsWithBypass<TDocument>]: (payload: Parameters<CollectionFunctionsWithBypass<TDocument>[P]>[0], context: Context<TDescription, TFunctions>) => ReturnType<CollectionFunctions<TDocument>[P]>;
|
|
74
|
-
};
|
|
80
|
+
export {};
|
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> = {
|
|
68
|
+
[P in keyof T]: PackReferencesAux<T[P]>;
|
|
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
|
|
92
|
+
type PackReferencesAux<T> = T extends (...args: any[]) => any ? T : T extends {
|
|
93
93
|
_id: infer Id;
|
|
94
|
-
} ?
|
|
94
|
+
} ? Id : T extends Record<string, any> ? PackReferences<T> : T extends any[] | readonly any[] ? PackReferencesAux<T[number]>[] : T;
|
|
95
95
|
type CombineProperties<TSchema> = TSchema extends {
|
|
96
96
|
properties: infer Properties;
|
|
97
97
|
} ? FilterReadonlyProperties<Properties> extends infer ReadonlyProperties ? Readonly<ReadonlyProperties> & {
|