UNPKG

@umbraco/headless-client

Version:
94 lines (93 loc) 4.77 kB
import { Client } from '../../Client'; import { ContentDeliveryAncestorsOptions, ContentDeliveryByContentTypeOptions, ContentDeliveryByIdOptions, ContentDeliveryByUrlOptions, ContentDeliveryChildrenOptions, ContentDeliveryDescendantsOptions, ContentDeliveryRootOptions, ContentDeliverySearchOptions, ContentDeliveryFilterOptions } from '../../RequestOptions'; import { Content } from '../../Responses'; import { PagedResponse } from '../../Responses/PagedResponse'; import { ContentFilter } from '../../RequestOptions/ContentFilterOptions'; /** * ContentDeliveryClient is used to access the Content part of the Content Delivery API. * @public * * @example * The {@link ContentDeliveryClient} must be accessed through {@link Client}. * * ```typescript * import { Client } from '@umbraco/headless-client' * * const client = new Client({ * projectAlias: '<your-project-alias>', * apiKey: '<your-api-key>', * language: '<iso-code>', * }) * * const contentClient = client.delivery.content * ``` */ export declare class ContentDeliveryClient { private readonly client; /** @internal */ constructor(client: Client); private readonly makeRequest; /** * Fetch all Content at the root. * * @param options - Request options. See {@link ContentDeliveryRootOptions}. * @returns a `Promise` that resolves to an array of {@link Content}. */ root<T extends Content>(options?: ContentDeliveryRootOptions): Promise<T[]>; /** * Fetch a single Content item by its id. * @param id - GUID id of the Content item. * @param options - Request options. See {@link ContentDeliveryByIdOptions}. * @returns a `Promise` that resolves to a {@link Content} if found, otherwise `undefined`. */ byId<T extends Content>(id: string, options?: ContentDeliveryByIdOptions): Promise<T | undefined>; /** * Feth a single Contint item by its Url. * @param url - Url for the content to retrieve. * @param options - Request options. See {@link ContentDeliveryByUrlOptions}. * @returns a `Promise` that resolves to a {@link Content} if found, otherwise `undefined`. */ byUrl<T extends Content>(url: string, options?: ContentDeliveryByUrlOptions): Promise<T | undefined>; /** * Fetch children for a Content item. * @param id - GUID id of the Content item. * @param options - Request options. See {@link ContentDeliveryChildrenOptions}. * @returns a `Promise` that resolves to a {@link PagedResponse} of {@link Content} if found, otherwise `undefined`. */ children<T extends Content>(id: string, options?: ContentDeliveryChildrenOptions): Promise<PagedResponse<T> | undefined>; /** * Fetch ancestors for a content item. * @param id - GUID id of the Content item. * @param options - Request options. See {@link ContentDeliveryAncestorsOptions}. * @returns a `Promise` that resolves to an array of {@link Content} if found, otherwise `undefined`. */ ancestors(id: string, options?: ContentDeliveryAncestorsOptions): Promise<Content[] | undefined>; /** * Fetch descendants for a content item. * @param id - GUID id of the Content item. * @param options - Request options. See {@link ContentDeliveryDescendantsOptions}. * @returns a `Promise` that resolves to an array of {@link Content} if found, otherwise `undefined`. */ descendants(id: string, options?: ContentDeliveryDescendantsOptions): Promise<PagedResponse<Content> | undefined>; /** * Fetch Content of a specific type. * @param contentType - Content Type to filter by. * @param options - Request options. See {@link ContentDeliveryByContentTypeOptions} * @returns a `Promise` that resolves to a {@link PagedResponse} of {@link Content}. */ byContentType<T extends Content>(contentType: string, options?: ContentDeliveryByContentTypeOptions): Promise<PagedResponse<T>>; /** * Filter for Content containing specific property values * @param contentFilter - Filter object. See {@link ContentFilter} * @param options - Request options. See {@link ContentDeliveryFilterOptions} * @returns a `Promise` that resolves to a {@link PagedResponse} of {@link Content}. */ filter<T extends Content>(body: ContentFilter, options?: ContentDeliveryFilterOptions): Promise<PagedResponse<T>>; /** * Search for Content containing term, * @param term - Term to search for * @param options - Request options. See {@link ContentDeliverySearchOptions} * @returns a `Promise` that resolves to a {@link PagedResponse} of {@link Content}. */ search<T extends Content>(term: string, options?: ContentDeliverySearchOptions): Promise<PagedResponse<T>>; }