import { Id } from "./CRMWebAPI";
import { Client } from "./client";
export interface LabelValue {
    Label: string;
    Value: number;
}
/** From OptionSet. */
export interface Option extends LabelValue {
    Description?: string;
}
export interface MetadataBase {
    MetadataId: string;
}
export interface EntityDefinition extends MetadataBase {
    SchemaName: string;
    LogicalName: string;
    PrimaryIdAttribute: string;
    LogicalCollectionName: string;
    IconSmallName: string | null;
    Description?: string;
    DisplayName?: string;
    Attributes?: Array<Attribute>;
}
export interface Relationship extends MetadataBase {
    ReferencedAttribute: string;
    ReferencedEntity: string;
    ReferencedEntityNavigationPropertyName: string;
    ReferencingAttribute: string;
    ReferencingEntity: string;
    ReferencingEntityNavigationPropertyName: string;
    RelationshipType: string;
    SchemaName: string;
    IsManaged: boolean;
    IsHierarchical: boolean;
    /** OOTB or created through customization. */
    IsCustomRelationship: boolean;
}
/**
 * 1:N => Referenced is the 1 side. For example, for all contact.OneToManyRelationships,
 * the ReferenceEntity is always "contact".
 */
export interface OneToManyRelationship extends Relationship {
}
/**
 * N:1 => Referenced is the N side. For example, for all contact.ManyToOneRelationships,
 * the ReferencingEntity is always "contact".
 */
export interface ManyToOneRelationship extends OneToManyRelationship {
}
export interface BlahValue {
    Value: boolean;
    CanBeChanged: boolean;
    ManagedPropertyLogicalName: string;
}
export interface Localized {
    HasChanged: boolean | null;
    IsManaged: boolean;
    Label: string | null;
    LanguageCode: number;
    MetadataId: string;
}
export interface LocalizedLabels {
    UserLocalizedLabel: Localized;
    LocalizedLabels: Array<Localized>;
}
/**
 * Return the user localized label using lcid if its provided and found.
 */
export declare function getLabel(labels: LocalizedLabels, lcid?: number): Localized | null;
/** Simple attribute. */
export interface Attribute extends MetadataBase {
    LogicalName: string;
    AttributeOf: string | null;
    AttributeType: string;
    AttributeTypeName: {
        Value: string;
    };
    ColumnNumber: number;
    DatabaseLength: number | null;
    Description: LocalizedLabels;
    DisplayName: LocalizedLabels;
    EntityLogicalName: string;
    ExternalName: string | null;
    FormulaDefinition: string | null;
    HasChanged: boolean | null;
    RequiredLevel: any;
    IsAuditEnabled: BlahValue;
    IsCustomAttribute: boolean;
    IsCustomizable: BlahValue;
    IsDataSourceSecret: boolean;
    IsFilterable: boolean;
    IsGlobalFilterEnabled: BlahValue;
    IsLocalizable: boolean;
    IsLogical: boolean;
    IsManaged: boolean;
    IsPrimaryId: boolean;
    IsPrimaryName: boolean;
    IsRenameable: BlahValue;
    IsRequiredForForm: boolean;
    /** Use this to find retrievable attributes. */
    IsRetrievable: boolean;
    IsSearchable: boolean;
    IsSecured: boolean;
    IsSortableEnabled: BlahValue;
    IsValidForAdvancedFind: BlahValue;
    IsValidForCreate: boolean;
    IsValidForForm: boolean;
    IsValidForGrid: boolean;
    IsValidForRead: boolean;
    IsValidForUpdate: boolean;
    LinkedAttributeId: string | null;
    MaxLength: number;
    SourceType: number;
    SourceTypeMask: number;
}
export interface LookupAttribute extends Attribute {
    /** Array of logical entity names that can be looked up. */
    Targets: Array<string>;
}
export interface ObjectTypeCodePair {
    LogicalName: string;
    ObjectTypeCode: number;
}
/** Connection role categories. Classifies a ConnectionRole. Value is the fk. */
export interface ConnectionRoleCategory {
    Label: string;
    Value: number;
}
/** Set of all connection roles. */
export interface ConnectionRole {
    connectionroleid: string;
    name: string;
    /** FK to ConnectionRoleCategory */
    category: number;
    /** Name of ConnectionRoleCategory */
    ["category@OData.Community.Display.V1.FormattedValue"]: string;
    description: string;
    statecode: number;
    statuscode: number;
    /** http link to reciprocals. */
    ["connectionroleassociation_association@odata.nextLink"]: string;
}
/**
 * An entry describing the type of object a connection role can connect to.
 */
export interface ConnectionRoleObjectTypeCode {
    /** Same as associatedobjecttypecode. */
    entityName: string;
    /** Same as _connectionroleid_value_formatted. */
    roleName: string;
    connectionroleobjecttypecodeid: Id;
    /** Logical name of allowed entity e.g. contact or systemuser. */
    associatedobjecttypecode: string;
    /** Display name of allowed entity e.g systemuser => User. */
    "associatedobjecttypecode@OData.Community.Display.V1.FormattedValue": string;
    /** Display name of allowed entity. */
    associatedobjecttypecode_formatted: string;
    organizationid: Id;
    /** Connection role's id's */
    _connectionroleid_value: Id;
    /** The connection role's display name .*/
    "_connectionroleid_value@OData.Community.Display.V1.FormattedValue": string;
    /** The connection role's display name. */
    _connectionroleid_value_formatted: string;
}
/**
 * Metadata API. Fetched metadata is shared among all instances of this class at the moment.
 */
export declare class Metadata {
    constructor(client: Client, lcid?: number);
    private lcid;
    private client;
    getLabel(labels: LocalizedLabels): Localized | null;
    /** Get all attributes for a logical entity name or return [] */
    getAttributes: (entityName: string) => Promise<Attribute[]>;
    /** Find a specific entity-attribute metadata. Return null if not found. */
    lookupAttribute: <T = Attribute>(entityName: string, attributeName: string) => Promise<T | null>;
    /** Returns all entity {LogicalName, ObjectTypeCode} pairs. */
    getObjectTypeCodes: () => Promise<ObjectTypeCodePair[]>;
    /** Given a numerical code, return the (LogicalName, ObjectTypeCode) pair. */
    lookupObjectTypeCodeByCode(code: number): Promise<ObjectTypeCodePair | undefined>;
    /** Given a name, return the (LogicalName, ObjectTypeCode) pair. */
    lookupObjectTypeCodeByName: (name: string) => Promise<ObjectTypeCodePair | undefined>;
    /** Pass in the entity singular logical name. Returns null if not found. Pulls all attributes but no navs. */
    getMetadata: (entityName: string) => Promise<EntityDefinition | null>;
    /** Get the entity set name given the entity logical name e.g. contact => contacts. */
    getEntitySetName: (logicalName: string) => Promise<string | null>;
    /** Get the schema name given the entity logical name. */
    getSchemaName: (logicalName: string) => Promise<string | null>;
    /** Return all connection roles. */
    getConnectionRoles: () => Promise<ConnectionRole[]>;
    /** Get "reciprocal" ConnectionRoles. You'll need to lookup the id using `getConnectionRoleById`. */
    getConnectionRoleAssociatedConnectionRoles: (connectionRoleId: string) => Promise<string[]>;
    /**
     * Return an array of connection roles for a given connection category name.
     *
     * TODO: Rewrite this so it does not need a filter, just use the id lookup cache.
     */
    getConnectionRolesForCategoryNamed: (categoryName: string) => Promise<ConnectionRole[]>;
    getConnectionRoleByCategoryAndName: (categoryName: string, roleName: string) => Promise<ConnectionRole | null>;
    /** Return a connection role by its id. */
    getConnectionRoleById: (id: string) => Promise<ConnectionRole | null>;
    /** Return a connection role by its name. */
    getConnectionRoleByName: (name: string) => Promise<ConnectionRole | null>;
    /** Return an array of connection role categories. */
    getConnectionRoleCategories: () => Promise<ConnectionRoleCategory[]>;
    /** Return a connecton role category by value (Category = OptionSet). */
    getConnectionRoleCategoryByValue: (value: number) => Promise<ConnectionRoleCategory | undefined>;
    /** Return a connection role category its name. */
    getConnectionRoleCategoryByName: (name: string) => Promise<ConnectionRoleCategory | undefined>;
    /**
     * Obtain the list of allowed object type. Empty means any entity type is allowed.
     */
    getAllowedTypeCodesForConnectionRoleId: (roleId: string) => Promise<ConnectionRoleObjectTypeCode[]>;
    /**
     * Get Option pairs back, Label and Value or an empty list..
     * Hackey implementation. Only looks at Attribute.OptionSet not Attribute.GlobalOptionSet.
     * Not cached yet!!!
     */
    getOptionSet: (entityLogicalName: string, attributeLogicalName: string) => Promise<Option[]>;
    /**
     * Return all activity types. How do we filter on non-published kinds?
     * This may return a surprising number of activities that are used only
     * in a specialized context so you absolutely will need to filter this list
     * down for use in your application.
     */
    getAllActivityTypes: () => Promise<EntityDefinition[]>;
    /** Retur the primary PK logical attribute name for a given entity. */
    getPk: (entityLogicalName: string) => Promise<string | null>;
    /** Relationships. Returns empty array if not found. */
    getOneToManyRelationships: (entityLogicalName: string) => Promise<OneToManyRelationship[]>;
    /** Get a 1:M relationship to a specific name. Could be multiple, so choose wisely. */
    getOneToManyRelationshipsTo: (entityLogicalName: string, toEntityLogicalName: string) => Promise<OneToManyRelationship[]>;
    /** Should be only one. null if not found. */
    getOneToManyRelationshipBySchemaName: (entityLogicalName: string, schemaName: string) => Promise<OneToManyRelationship | null>;
    getManyToOneRelationships: (entityLogicalName: string) => Promise<ManyToOneRelationship[]>;
    getManyToOneRelationshipsFrom: (entityLogicalName: string, fromEntityLogicalName: string) => Promise<ManyToOneRelationship[]>;
    getManyToOneRelationshipBySchemaName: (entityLogicalName: string, schemaName: string) => Promise<ManyToOneRelationship | null>;
}
export default Metadata;
/** Something that can provide a metadata object. */
export interface MetadataProvider {
    metadata: Metadata;
}
