@aeriajs/types 0.0.104 → 0.0.105

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.
@@ -24,8 +24,9 @@ type RemoveAny<T> = {
24
24
  };
25
25
  export type StrictFilter<TDocument> = RemoveAny<Filter<DocumentFilter<TDocument>>>;
26
26
  export type StrictFilterOperators<TDocument> = RemoveAny<FilterOperators<DocumentFilter<TDocument>>>;
27
+ type FlattenObjectKeys<T> = T extends T & 0 ? never : T extends Record<infer K, unknown> ? K extends string ? T[K] extends Record<string, unknown> ? `${K}.${FlattenObjectKeys<T[K]>}` : K : never : never;
27
28
  export type Filters<TDocument> = StrictFilter<TDocument> & Partial<{
28
- [P in keyof TDocument | `${Extract<keyof TDocument, string>}.${string}`]: (P extends keyof TDocument ? TDocument[P] extends infer Field ? Field extends ObjectId ? Field | string : Field extends {
29
+ [P in keyof TDocument | FlattenObjectKeys<TDocument>]: (P extends keyof TDocument ? TDocument[P] extends infer Field ? Field extends ObjectId ? Field | string : Field extends {
29
30
  _id: infer Id;
30
31
  } ? Id | string : Field : never : unknown) extends infer Field ? Field | StrictFilterOperators<Field> | null : never;
31
32
  }>;
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import type { ObjectId } from 'mongodb';
2
+ type Prettify<T> = {
3
+ [K in keyof T]: T[K];
4
+ } & {};
2
5
  type Owned = {
3
6
  owner?: Collections['user']['item'];
4
7
  };
@@ -51,10 +54,10 @@ export type InferSchema<TSchema, TSchemaOptions extends SchemaOptions = {}> = Me
51
54
  } ? Partial<MappedTypes> : TSchema extends {
52
55
  required: infer InferredRequired;
53
56
  } ? ExtractRequiredPropNames<InferredRequired> extends infer RequiredPropName ? Pick<MappedTypes, Extract<keyof MappedTypes, RequiredPropName>> extends infer RequiredProps ? RequiredProps & Partial<Exclude<MappedTypes, keyof RequiredProps>> : never : Partial<MappedTypes> : MappedTypes : never;
54
- export type Schema<TSchema, TSchemaOptions extends SchemaOptions = {}> = CaseTimestamped<TSchema, CaseOwned<TSchema, InferSchema<TSchema, TSchemaOptions>>>;
55
- export type SchemaWithId<TSchema, TSchemaOptions extends SchemaOptions = {}> = Schema<TSchema, TSchemaOptions> & {
57
+ export type Schema<TSchema, TSchemaOptions extends SchemaOptions = {}> = Prettify<CaseTimestamped<TSchema, CaseOwned<TSchema, InferSchema<TSchema, TSchemaOptions>>>>;
58
+ export type SchemaWithId<TSchema, TSchemaOptions extends SchemaOptions = {}> = Prettify<Schema<TSchema, TSchemaOptions> & {
56
59
  _id: ObjectId;
57
- };
60
+ }>;
58
61
  export type InferProperties<TSchema> = TSchema extends readonly unknown[] ? TSchema extends readonly (infer SchemaOption)[] ? SchemaOption extends unknown ? SchemaOption extends {
59
62
  $ref: infer K;
60
63
  } | {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/types",
3
- "version": "0.0.104",
3
+ "version": "0.0.105",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",