import type { AnyRealmObject } from "./Object"; import type { AnyCollection } from "./Collection"; import type { Counter } from "./Counter"; import type { AnyDictionary, Dictionary } from "./Dictionary"; import type { AnyList, List } from "./List"; import type { AnySet, RealmSet } from "./Set"; type ExtractPropertyNamesOfType = { [K in keyof T]: T[K] extends PropType ? K : never; }[keyof T]; type ExtractPropertyNamesOfTypeExcludingNullability = { [K in keyof T]: Exclude extends PropType ? K : never; }[keyof T]; /** * Exchanges properties defined as {@link List} with an optional {@link Array}. */ type RealmListRemappedModelPart = { [K in ExtractPropertyNamesOfType]?: T[K] extends List ? Array> : never; }; /** * Exchanges properties defined as {@link Dictionary} with an optional key to mixed value object. */ type RealmDictionaryRemappedModelPart = { [K in ExtractPropertyNamesOfType]?: T[K] extends Dictionary ? { [key: string]: ValueType; } : never; }; /** * Exchanges properties defined as {@link RealmSet} with an optional {@link Array}. */ type RealmSetRemappedModelPart = { [K in ExtractPropertyNamesOfType]?: T[K] extends RealmSet ? Array> : never; }; /** * Exchanges properties defined as a {@link Counter} with a `number`. */ type RealmCounterRemappedModelPart = { [K in ExtractPropertyNamesOfTypeExcludingNullability]?: Counter | number | Exclude; }; /** Omits all properties of a model which are not defined by the schema */ export type OmittedRealmTypes = Omit | ExtractPropertyNamesOfType | ExtractPropertyNamesOfType | ExtractPropertyNamesOfTypeExcludingNullability>; /** Make all fields optional except those specified in K */ type OptionalExcept = Partial & Pick; /** * Omits all properties of a model which are not defined by the schema, * making all properties optional except those specified in RequiredProperties. */ type OmittedRealmTypesWithRequired> = OptionalExcept, RequiredProperties>; /** Remaps realm types to "simpler" types (arrays and objects) */ type RemappedRealmTypes = RealmListRemappedModelPart & RealmDictionaryRemappedModelPart & RealmSetRemappedModelPart & RealmCounterRemappedModelPart; /** * Joins `T` stripped of all keys which value extends {@link Collection} and all inherited from {@link Realm.Object}, * with only the keys which value extends {@link List}, remapped as {@link Array}. All properties are optional * except those specified in `RequiredProperties`. */ export type Unmanaged = never> = OmittedRealmTypesWithRequired & RemappedRealmTypes; export {};