import type * as UID from '../../uid'; import type { Constants, Guard, And, Extends, IsNotNever } from '../../utils'; import type { Attribute } from '..'; /** * Determines if a given attribute type is of a specific kind. * * @template TAttribute - The attribute type to check. * @template TKind - The kind of attribute to compare against. */ export type IsOfType = TAttribute extends { type: TKind; } ? true : false; /** * Checks whether a given Attribute {@link TAttribute} is populatable. * * @template TAttribute - The attribute to check. * * @see {@link PopulatableKind} for more information about populatable attributes. */ export type IsPopulatable = IsOfType; /** * Returns the type (as {@link Kind}) of a given attribute. * * @template TAttribute - Any attribute */ export type TypeOf = TAttribute['type']; /** * Extract the target of an attribute. * * Returns never if the attribute don't have a target. * * Returns {@link UID.Schema} if a valid target is found * * @template TAttribute - The attribute to use * * @remark Targets can only be inferred from relation, component, and media attributes. */ export type Target = Attribute.RelationTarget | Attribute.ComponentTarget | Attribute.MediaTarget; /** * Extract the potential targets of a polymorphic attribute. * * Returns never if the attribute don't have any target. * * Returns {@link UID.Schema} if valid targets are found * * @template TAttribute - The attribute to use * * @remark Morph targets can only be inferred from dynamic-zone attributes. */ export type MorphTargets = Attribute.DynamicZoneTargets; /** * Checks whether an attribute has a valid target. * * @template TAttribute - The attribute to check * * @see Target * * @remark Targets can only be inferred from relation, component, and media attributes. */ export type HasTarget = Target extends infer TTarget ? And, Extends> : Constants.False; /** * Checks whether an attribute has valid targets. * * @template TAttribute - The attribute to check * * @see MorphTargets * * @remark Targets can only be inferred from dynamic-zone attributes. */ export type HasMorphTargets = MorphTargets extends infer TMaybeTargets ? And, Extends> : Constants.False; /** * Represents the actual value of a given attribute {@link TAttribute}. * * @template TAttribute - The attribute to extract the value from. * @template TGuard - The fallback type to use if it's not possible to infer the correct type value. */ export type Value = Guard.Never<{ biginteger: Attribute.GetBigIntegerValue; boolean: Attribute.GetBooleanValue; blocks: Attribute.GetBlocksValue; decimal: Attribute.GetDecimalValue; enumeration: Attribute.GetEnumerationValue; email: Attribute.GetEmailValue; float: Attribute.GetFloatValue; integer: Attribute.GetIntegerValue; json: Attribute.GetJsonValue; password: Attribute.GetPasswordValue; richtext: Attribute.GetRichTextValue; string: Attribute.GetStringValue; text: Attribute.GetTextValue; uid: Attribute.GetUIDValue; date: Attribute.GetDateValue; datetime: Attribute.GetDateTimeValue; time: Attribute.GetTimeValue; timestamp: Attribute.GetTimestampValue; component: Attribute.GetComponentValue; dynamiczone: Attribute.GetDynamicZoneValue; media: Attribute.GetMediaValue; relation: Attribute.GetRelationValue; }[Attribute.TypeOf], TGuard>; //# sourceMappingURL=utils.d.ts.map