@umbraco/headless-client
Version:
Node.js client library for the Umbraco Headless APIs
202 lines (201 loc) • 6.17 kB
TypeScript
import { Client } from '../../Client';
import { ContentManagementClient } from './ContentManagementClient';
import { MediaManagementClient } from './MediaManagementClient';
import { MemberManagementClient } from './MemberManagementClient';
import { ContentLanguageType, ContentMemberCreateGroupType, ContentMemberGroupType, ContentMemberTypeType, ContentTypeBase, ContentRelationType, ContentRelationTypeType, CreateContentLanguageType, MediaTypeContentManager, Form } from '../../Responses';
/**
* ManagementClient is used to access the Content Management API.
* @public
*
* @example
* The {@link ManagementClient} 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 managementClient = client.management
* ```
*/
export declare class ManagementClient {
private readonly client;
/**
* @internal
*/
constructor(client: Client);
private readonly makeRequest;
/**
* The Content client for the Content Management API.
* See {@link ContentManagementClient}
*/
readonly content: ContentManagementClient;
/**
* The Media client for the Media Management API.
* See {@link MediaManagementClient}
*/
readonly media: MediaManagementClient;
/**
* The Member client for the Member Management API.
* See {@link MemberManagementClient}
*/
readonly member: MemberManagementClient;
/**
* ContentType API
*/
get contentType(): {
/**
* Fetch all content types
*/
all: <R extends ContentTypeBase>() => Promise<R[]>;
/**
* Find content type by alias
* @param alias Alias for the content type
*/
byAlias: (alias: string) => Promise<ContentTypeBase>;
};
/**
* Media API
*/
get mediaType(): {
/**
* Fetch all media types
*/
all: () => Promise<MediaTypeContentManager[]>;
/**
* Find media type by alias
* @param alias Alias of the media type querying for
*/
byAlias: (alias: string) => Promise<MediaTypeContentManager>;
};
/**
* Language API
*/
get language(): {
/**
* Fetch all languages
*/
all: <R extends ContentLanguageType>() => Promise<R[]>;
/**
* Find language by ISO code
* @param id ISO Code for the language (e.g. en-US)
*/
byISOCode: <R_1 extends ContentLanguageType>(id: string) => Promise<R_1>;
/**
* Create a language
* @param data Data for creating language object
*/
create: <R_2 extends ContentLanguageType>(data: CreateContentLanguageType) => Promise<R_2>;
/**
* Update a language
* @param id ISO Code for the language (e.g. en-US)
* @param data Data for updating language object
*/
update: <R_3 extends ContentLanguageType>(id: string, data: CreateContentLanguageType) => Promise<R_3>;
/**
* Delete a language
* @param id ISO Code for the language (e.g. en-US)
*/
delete: <R_4 extends ContentLanguageType>(id: string) => Promise<R_4>;
};
/**
* Relation API
*/
get relation(): {
/**
* Find relation by id
* @param id GUID part of an Umbraco UDI
*/
byId: (id: string) => Promise<ContentRelationType>;
/**
* Find relation by alias
* @param alias Alias of the relation querying for
*/
byAlias: (alias: string) => Promise<ContentRelationType[]>;
/**
* Fetch child for relation with id
* @param id GUID part of an Umbraco UDI
*/
byChild: (id: string) => Promise<ContentRelationType[]>;
/**
* Fetch parent for relation with id
* @param id GUID part of an Umbraco UDI
*/
byParent: (id: string) => Promise<ContentRelationType[]>;
/**
* Create a relation
* @param data Data for creating relation object
*/
create: (data: any) => Promise<ContentRelationType>;
/**
* Delete relation with id
* @param id GUID part of an Umbraco UDI
*/
delete: (id: string) => Promise<ContentRelationType>;
};
/**
* RelationType API
*/
get relationType(): {
/**
* Fetch relation type by alias
* @param alias Alias for the relation type queryed for
*/
byAlias: (alias: string) => Promise<ContentRelationTypeType>;
};
/**
* MemberGroup API
*/
get memberGroup(): {
/**
* Fetch member group by name
* @param name The name of the group
*/
byName: (name: string) => Promise<ContentMemberGroupType>;
/**
* Create a member group
* @param data Data for creating a member group
*/
create: (data: ContentMemberCreateGroupType) => Promise<ContentMemberGroupType>;
/**
* Delete member group
* @param name Name of the member group to be removed
*/
delete: (name: string) => Promise<ContentMemberGroupType>;
};
/**
* MemberType API
*/
get memberType(): {
/**
* Fetch all member types
*/
all: <R extends ContentMemberTypeType>() => Promise<R[]>;
/**
* Find by alias
* @param alias Alias for the member type to be found.
*/
byAlias: <R_1 extends ContentMemberTypeType>(alias: string) => Promise<R_1>;
};
/**
* Forms API
*/
get forms(): {
/**
* Fetch all forms
*/
all: () => Promise<Form[]>;
/**
* Get form by id
*/
byId: (id: string) => Promise<Form>;
/**
* Submit a new form entry
*/
submitEntry: (formId: string, data: object) => Promise<any>;
};
}