@tensorify.io/sdk
Version:
TypeScript SDK for developing Tensorify plugins with comprehensive validation, frontend enforcement, and publishing tools
152 lines • 5.69 kB
TypeScript
/**
* TensorifyPlugin - The core abstract class for all Tensorify plugins
*
* This is the single class that all plugin developers must extend.
* It enforces frontend requirements, provides validation, and handles
* manifest generation for the CLI publishing system.
*/
import { PluginSettings, PluginCodeGenerationContext, NodeType, PluginCapability, PluginRequirements } from "../types/core";
import { IPluginDefinition, FrontendPluginManifest, PackageJsonInfo, PluginValidationResult } from "../types/plugin";
import { InputHandle, OutputHandle, NodeVisualConfig } from "../types/visual";
import { SettingsField, SettingsGroup } from "../types/settings";
/**
* Abstract base class for all Tensorify plugins
*
* Every plugin must extend this class and implement the required methods.
* This class enforces frontend visual requirements and provides utilities
* for plugin development.
*/
export declare abstract class TensorifyPlugin {
/** Plugin definition containing all configuration */
protected readonly definition: IPluginDefinition;
/** Current SDK version */
private static readonly SDK_VERSION;
/** Manifest format version */
private static readonly MANIFEST_VERSION;
/**
* Constructor - Creates a new plugin instance
* @param definition Complete plugin definition
*/
constructor(definition: IPluginDefinition);
/**
* Generate executable code for this plugin
*
* This is the core method that every plugin must implement.
* It generates the actual code that will be executed in the workflow.
*
* @param settings Plugin settings extending CorePluginSettings
* @param children Connected child plugins (keep as any for flexibility)
* @param context Code generation context with input data access
* @returns Generated code as string
*/
abstract getTranslationCode(settings: PluginSettings, children?: any, context?: PluginCodeGenerationContext): string;
/**
* Helper method to access input data from handles
*
* @param context Code generation context
* @param handleNumber Handle index (0-based)
* @returns Input data from the specified handle
*/
protected getInput(context: PluginCodeGenerationContext, handleNumber: number): any;
/**
* Get all input data as an array
*
* @param context Code generation context
* @returns Array of all input data
*/
protected getAllInputs(context: PluginCodeGenerationContext): any[];
/** Get plugin ID (may be undefined if not provided in definition) */
getId(): string | undefined;
/** Get plugin name (may be undefined if not provided in definition) */
getName(): string | undefined;
/** Get plugin description (may be undefined if not provided in definition) */
getDescription(): string | undefined;
/** Get plugin version (may be undefined if not provided in definition) */
getVersion(): string | undefined;
/** Get node type (may be undefined if not provided in definition) */
getNodeType(): NodeType | undefined;
/** Get visual configuration */
getVisualConfig(): NodeVisualConfig;
/** Get input handles */
getInputHandles(): InputHandle[];
/** Get output handles */
getOutputHandles(): OutputHandle[];
/** Get settings fields */
getSettingsFields(): SettingsField[];
/** Get settings groups */
getSettingsGroups(): SettingsGroup[];
/** Get capabilities */
getCapabilities(): PluginCapability[];
/** Get requirements */
getRequirements(): PluginRequirements;
/** Get complete definition */
getDefinition(): IPluginDefinition;
/**
* Validate plugin settings before code generation
*
* @param settings Settings to validate
* @returns Validation result
*/
validateSettings(settings: PluginSettings): PluginValidationResult;
/**
* Validate the plugin definition structure
*/
private validateDefinition;
/**
* Validate visual configuration
*/
private validateVisualConfig;
/**
* Validate handle configurations
*/
private validateHandles;
/**
* Validate settings fields configuration
*/
private validateSettingsFields;
/**
* Validate individual field data type
*/
private validateFieldDataType;
/**
* Validate field-specific rules
*/
private validateFieldRules;
/**
* Derive plugin ID from package name
* @param packageName Package name (e.g., "@org/my-plugin" or "my-plugin")
* @returns Derived plugin ID
*/
private derivePluginId;
/**
* Derive nodeType from package.json tensorify.pluginType
* @param pluginType Plugin type from package.json tensorify section
* @returns Derived NodeType or default to CUSTOM
*/
private deriveNodeType;
/**
* Generate frontend manifest for CLI publishing
*
* @param packageInfo Package.json information
* @param entrypointClassName Exact class name for instantiation
* @returns Frontend plugin manifest
*/
generateManifest(packageInfo: PackageJsonInfo, entrypointClassName: string): FrontendPluginManifest;
/**
* Create default settings object from field definitions
*/
createDefaultSettings(): PluginSettings;
/**
* Process dynamic label template with settings values
*/
generateDynamicLabel(settings: PluginSettings): string;
/**
* Get current SDK version
*/
static getSDKVersion(): string;
/**
* Get manifest format version
*/
static getManifestVersion(): string;
}
//# sourceMappingURL=TensorifyPlugin.d.ts.map