import type * as Public from '../public'; import type * as UID from '../uid'; import type { If, Object, Guard } from '../utils'; import type * as Attribute from './attribute'; export { Attribute }; /** * Combines both content type and component schemas, effectively serving as a consolidated registry of all schemas. * * Enables mapping between a unique identifier and its corresponding schema. * @remark Schema definitions are pulled from the public registries */ export type Schemas = Public.ContentTypeSchemas & Public.ComponentSchemas; /** * Content-type schema definitions. * * @remark Schema definitions are pulled from the public content-type registries */ export type ContentTypes = Public.ContentTypeSchemas; /** * Component schema definitions. * * @remark Schema definitions are pulled from the public component registries */ export type Components = Public.ComponentSchemas; export type ContentType = ContentTypes[TContentTypeUID]; export type Component = Components[TComponentUID]; /** * Returns the Schema data structure associated with the given UID * * @template TSchemaUID - The unique identifier for the schema. * * @see Schemas */ export type Schema = Schemas[TSchemaUID]; /** * Returns the `info` property for a given schema. * * @template TSchemaUID - The targeted schema UID. * * @see Schema */ export type Info = Schema['info']; /** * Returns the `modelType` property for a given schema. * * @template TSchemaUID - The targeted schema UID. * * @see Schema */ export type ModelType = Schema['modelType']; /** * Returns the attribute {@link TAttributeName} from {@link TSchemaUID}'s attributes. * * @template TSchemaUID - The Schema's UID used to look for attributes. * @template TAttributeName - The name of the wanted attribute. */ export type AttributeByName> = Attributes[TAttributeName]; /** * Represents the value of an attribute based on its name * * @template TSchemaUID - The Schema's UID used to look for attributes. * @template TAttributeName - The name of the wanted attribute. */ export type AttributeValueByName> = Attribute.Value>; /** * Returns an object containing every attribute within {@link TSchemaUID}. * * @template TSchemaUID - The Schema's UID used to get its attributes */ export type Attributes = { [TUID in TSchemaUID]: Schema['attributes']; }[TSchemaUID]; /** * Union type of every attribute name within {@link TSchemaUID}'s attributes * * @template TSchemaUID - The Schema's UID used to get the attributes names. */ export type AttributeNames = Extract, string>; /** * Create an attribute record whose types matches the given ones. * * @template TSchemaUID - The Schema's UID used to get the attribute names. * @template TKind - The kind of attribute we are searching for. * @template TCondition - Optional. An additional condition to match additional attributes properties. */ export type AttributesByType = Object.PickBy, Attribute.OfType & Guard.Never>; /** * Returns a union of attribute names whose type matches the given ones. * * @template TSchemaUID - The Schema's UID used to get the attribute names. * @template TKind - The kind of attribute we are searching for. * @template TCondition - Optional. An additional condition to match additional attributes properties. */ export type AttributeNamesByType = Object.KeysBy, Attribute.OfType & Guard.Never, AttributeNames>; /** * Provides the names of non-populatable attributes of a Schema. * * Non-populatable attributes are those which do not need to be populated to get their final value. * * @template TSchemaUID - The unique identifier of the schema. */ export type NonPopulatableAttributeNames = AttributeNamesByType; /** * Provides the names of populatable attributes of a Schema. * * Populatable attributes are those which need to be populated to get their final value, such as {@link Attribute.Relation}, {@link Attribute.DynamicZone}, {@link Attribute.Component} or {@link Attribute.Media}. * * @template TSchemaUID - The unique identifier of the schema. */ export type PopulatableAttributeNames = AttributeNamesByType; /** * Returns a list of attribute names which have associated targets. * * @remark ` AttributeNamesWithTarget` maps over the list of attribute for a given schema and filters those * with targets (in other words, attribute names that have associated {@link Attribute.HasTarget} true). * * @returns a union of each attribute's name matching the condition. * * @template TSchemaUID - The unique identifier of the schema. */ export type AttributeNamesWithTarget = Extract]: If>, TKey>; }>, AttributeNames>; /** * Extracts the names of all required attributes from a given schema. * * @remark `RequiredAttributeNames` screens attributes based on the {@link Attribute.Required} property, * determining mandatory attributes from the given schema. * * @template TSchemaUID - The identifier of the schema. */ export type RequiredAttributeNames = Object.KeysBy, Attribute.Required, AttributeNames>; /** * Returns a union of every optional attribute name by excluding required attribute keys from the given Schema UID. * * @remark The ` OptionalAttributeNames` type utilises the {@link Object.KeysExcept} utility that takes a Schema's attributes and excludes the keys of required attributes. * * @template TSchemaUID - The unique identifier for the schema. */ export type OptionalAttributeNames = Object.KeysExcept, Attribute.Required, AttributeNames>; //# sourceMappingURL=index.d.ts.map