@imgly/plugin-ai-video-generation-web
Version:
AI video generation plugin for the CE.SDK editor
108 lines (107 loc) • 3.24 kB
TypeScript
import { type OpenAPIV3 } from 'openapi-types';
import CreativeEditorSDK, { CreativeEngine } from '@cesdk/cesdk-js';
import { Provider, RenderCustomProperty, VideoOutput, GetBlockInput, Middleware } from '@imgly/plugin-ai-generation-web';
import { VideoQuickActionSupportMap } from '../types';
type MiddlewareType = Middleware<any, any>;
/**
* Configuration for EachLabs video providers.
*/
export interface EachLabsProviderConfiguration {
/**
* HTTP endpoint URL for the EachLabs proxy. The proxy handles API key injection.
*/
proxyUrl: string;
/**
* Enable debug logging for provider creation and API calls.
*/
debug?: boolean;
/**
* Middleware functions to process inputs/outputs.
*/
middlewares?: MiddlewareType[];
/**
* Override provider's default history asset source.
*/
history?: false | '@imgly/local' | '@imgly/indexedDB' | (string & {});
/**
* Configure supported quick actions.
*/
supportedQuickActions?: {
[quickActionId: string]: Partial<VideoQuickActionSupportMap<any>[string]> | false | null;
};
}
/**
* Options for creating an EachLabs video provider.
*/
interface CreateProviderOptions<I extends Record<string, any>> {
/**
* EachLabs model slug (e.g., 'kling-v2-6-pro-text-to-video').
*/
modelSlug: string;
/**
* EachLabs model version (e.g., '0.0.1').
*/
modelVersion: string;
/**
* Unique provider identifier for registration.
*/
providerId: string;
/**
* Human-readable provider name displayed in the UI.
*/
name: string;
/**
* OpenAPI schema document describing the input parameters.
*/
schema: OpenAPIV3.Document;
/**
* JSON reference to the input schema (e.g., '#/components/schemas/Input').
*/
inputReference: string;
/**
* User flow mode for the provider panel.
*/
useFlow?: 'placeholder' | 'generation-only';
/**
* Initialization callback when the provider is registered.
*/
initialize?: (context: {
cesdk?: CreativeEditorSDK;
engine: CreativeEngine;
}) => void;
/**
* Custom property renderers for the input panel.
*/
renderCustomProperty?: RenderCustomProperty;
/**
* Quick actions this provider supports.
*/
supportedQuickActions?: VideoQuickActionSupportMap<I>;
/**
* Get block dimensions from input parameters.
*/
getBlockInput: GetBlockInput<'video', I>;
/**
* Transform input parameters to EachLabs API format.
*/
mapInput: (input: I) => Record<string, any>;
/**
* Provider-specific middleware functions.
*/
middleware?: MiddlewareType[];
/**
* Custom headers to include in API requests.
*/
headers?: Record<string, string>;
/**
* CE.SDK instance for image URL conversion.
*/
cesdk?: CreativeEditorSDK;
}
/**
* Creates an EachLabs video provider from schema.
*/
declare function createVideoProvider<I extends Record<string, any> & {
image_url?: string;
}>(options: CreateProviderOptions<I>, config: EachLabsProviderConfiguration): Provider<'video', I, VideoOutput>;
export default createVideoProvider;