@adobe/genstudio-extensibility-sdk
Version:
GenStudio Extensibility SDK
50 lines (49 loc) • 2.09 kB
TypeScript
import { VirtualApi } from "@adobe/uix-core";
import { Experience, FieldUpdate } from "../types/experience/Experience";
import { GenerationContext } from "../types/generationContext/GenerationContext";
export interface FragmentSwapExtensionApi extends VirtualApi {
api: {
fragmentSwapExtension: {
getExperience: () => Promise<Experience>;
getGenerationContext: () => Promise<GenerationContext>;
getSelectedField: () => Promise<FieldUpdate>;
setSwapValue: (value: string) => void;
};
};
}
export declare class FragmentSwapExtensionServiceError extends Error {
constructor(message: string);
}
/**
* Manages swap field extension functionality for swapping field content
*/
export declare class FragmentSwapExtensionService {
/**
* Gets the current field context from the host
* @param connection - The guest connection to the host
* @returns Promise<SwapFieldContext> The current field context
* @throws Error if connection is missing
*/
static getExperience(connection: any): Promise<Experience>;
/**
* Gets the generation context from the host
* @param connection - The guest connection to the host
* @returns Promise<GenerationContext> The generation context
* @throws Error if connection is missing
*/
static getGenerationContext(connection: any): Promise<GenerationContext>;
/**
* Gets the field currently being swapped, including its name and current value
* @param connection - The guest connection to the host
* @returns Promise<FieldUpdate> The selected field's experienceId, name, and current value
* @throws Error if connection is missing
*/
static getSelectedField(connection: any): Promise<FieldUpdate>;
/**
* Sets the swap value for the field content
* @param connection - The guest connection to the host
* @param value - The new value to write into the field
* @throws Error if connection is missing
*/
static setSwapValue(connection: any, value: string): void;
}