@contentstack/cli-variants
Version:
Variants plugin
79 lines (78 loc) • 5.35 kB
TypeScript
import { AdapterHelper } from './adapter-helper';
import { HttpClient } from '@contentstack/cli-utilities';
import { ProjectStruct, Personalization, GetProjectsParams, CreateProjectInput, CreateAttributeInput, APIConfig, GetVariantGroupInput, EventStruct, AudienceStruct, AttributeStruct, CreateAudienceInput, CreateEventInput, CreateExperienceInput, ExperienceStruct, UpdateExperienceInput, CMSExperienceStruct, VariantAPIRes, APIResponse, VariantGroupStruct, VariantGroup, CreateExperienceVersionInput, ExportConfig } from '../types';
export declare class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> implements Personalization<T> {
exportConfig?: ExportConfig;
constructor(options: APIConfig);
init(): Promise<void>;
projects(options: GetProjectsParams): Promise<ProjectStruct[]>;
/**
* This TypeScript function creates a project by making an asynchronous API call to retrieve project
* data.
* @param {CreateProjectInput} input - The `input` parameter in the `createProject` function likely
* represents the data needed to create a new project. It could include details such as the project
* name, description, owner, deadline, or any other relevant information required to set up a new
* project.
* @returns The `createProject` function is returning a Promise that resolves to either a
* `ProjectStruct` object or `void`.
*/
createProject(project: CreateProjectInput): Promise<ProjectStruct>;
/**
* The function `createAttribute` asynchronously retrieves attribute data from an API endpoint.
* @param {CreateAttributeInput} input - The `input` parameter in the `createAttribute` function is
* of type `CreateAttributeInput`. This parameter likely contains the necessary data or information
* needed to create a new attribute.
* @returns The `createAttribute` function is returning the data obtained from a GET request to the
* `/attributes` endpoint using the `apiClient` with the input provided. The data returned is of type
* `ProjectStruct`.
*/
createAttribute(attribute: CreateAttributeInput): Promise<AttributeStruct>;
getExperiences(): Promise<ExperienceStruct[]>;
getExperience(experienceUid: string): Promise<ExperienceStruct | void>;
getExperienceVersions(experienceUid: string): Promise<ExperienceStruct | void>;
createExperienceVersion(experienceUid: string, input: CreateExperienceVersionInput): Promise<ExperienceStruct | void>;
updateExperienceVersion(experienceUid: string, versionId: string, input: CreateExperienceVersionInput): Promise<ExperienceStruct | void>;
getVariantGroup(input: GetVariantGroupInput): Promise<VariantGroupStruct | void>;
updateVariantGroup(input: VariantGroup): Promise<VariantGroup | void>;
getEvents(): Promise<EventStruct[] | void>;
createEvents(event: CreateEventInput): Promise<void | EventStruct>;
getAudiences(): Promise<AudienceStruct[] | void>;
getAttributes(): Promise<AttributeStruct[] | void>;
/**
* @param {CreateAudienceInput} audience - The `audience` parameter in the `createAudience` function is
* of type `CreateAudienceInput`. This parameter likely contains the necessary data or information
* needed to create a new audience.
* @returns The `createAudience` function is returning the data obtained from a GET request to the
* `/audiences` endpoint using the `apiClient` with the input provided. The data returned is of type
* `AudienceStruct`.
*/
createAudience(audience: CreateAudienceInput): Promise<void | AudienceStruct>;
/**
* @param {CreateExperienceInput} experience - The `experience` parameter in the `createExperience` function is
* of type `CreateExperienceInput`. This parameter likely contains the necessary data or information
* needed to create a new audience.
* @returns The `createExperience` function is returning the data obtained from a GET request to the
* `/experiences` endpoint using the `apiClient` with the input provided. The data returned is of type
* `ExperienceStruct`.
*/
createExperience(experience: CreateExperienceInput): Promise<void | ExperienceStruct>;
/**
* @param {UpdateExperienceInput} experience - The `experience` parameter in the `updateCTsInExperience` function is
* of type `UpdateExperienceInput`. This parameter likely contains the necessary data or information
* needed to attach CT in new created experience.
*/
updateCTsInExperience(experience: UpdateExperienceInput, experienceUid: string): Promise<void | CMSExperienceStruct>;
/**
* @param {UpdateExperienceInput} experienceUid - The `experienceUid` parameter in the `getCTsFromExperience` function is
* of type `string`. This parameter likely contains the necessary data or information
* needed to fetch CT details related to experience.
*/
getCTsFromExperience(experienceUid: string): Promise<void | CMSExperienceStruct>;
/**
* Handles the API response for variant requests.
* @param res - The API response object.
* @returns The variant API response data.
* @throws If the API response status is not within the success range, an error message is thrown.
*/
handleVariantAPIRes(res: APIResponse): Promise<VariantAPIRes>;
}